mirror of
https://github.com/MiSTer-devel/Distribution_MiSTer.git
synced 2026-05-17 03:03:37 +00:00
Adding setname folders from MGL
This commit is contained in:
committed by
GitHub
parent
3c54000701
commit
2aaacd7a81
35
.github/calculate_db.py
vendored
35
.github/calculate_db.py
vendored
@@ -220,6 +220,13 @@ class Tags:
|
||||
if nodates in ['gba2p', 'gameboy2p']:
|
||||
self._append(result, self._use_term('handheld2p'))
|
||||
|
||||
elif suffix == '.mgl':
|
||||
self._append(result, self._use_term('cores'))
|
||||
self._append(result, self._use_term(stem))
|
||||
rbf, setname = read_mgl_fields(path)
|
||||
if rbf is not None:
|
||||
self._append(result, self._use_term(Path(rbf).name))
|
||||
|
||||
if parent == 'games':
|
||||
first_level = path.parts[1].lower()
|
||||
self._append(result, self._use_term(first_level))
|
||||
@@ -877,6 +884,34 @@ def read_mra_fields(mra_path):
|
||||
|
||||
return rbf, list(zips)
|
||||
|
||||
def read_mgl_fields(mgl_path):
|
||||
rbf = None
|
||||
setname = None
|
||||
|
||||
try:
|
||||
context = et_iterparse(str(mgl_path), events=("start",))
|
||||
for _, elem in context:
|
||||
elem_tag = elem.tag.lower()
|
||||
if elem_tag == 'rbf':
|
||||
if rbf is not None:
|
||||
print('WARNING! Duplicated rbf tag on file %s, first value %s, later value %s' % (str(mgl_path),rbf,elem.text))
|
||||
continue
|
||||
if elem.text is None:
|
||||
continue
|
||||
rbf = elem.text.strip().lower()
|
||||
elif setname == 'rom':
|
||||
if setname is not None:
|
||||
print('WARNING! Duplicated setname tag on file %s, first value %s, later value %s' % (str(mgl_path),setname,elem.text))
|
||||
continue
|
||||
if elem.text is None:
|
||||
continue
|
||||
setname = elem.text.strip().lower()
|
||||
except xml.etree.ElementTree.ParseError as e:
|
||||
print('ERROR: Defect XML for mgl file: ' + str(mgl_path))
|
||||
raise e
|
||||
|
||||
return rbf, setname
|
||||
|
||||
if __name__ == '__main__':
|
||||
dryrun = len(sys.argv) == 2 and sys.argv[1] == '-d'
|
||||
try:
|
||||
|
||||
30
.github/update_distribution.sh
vendored
30
.github/update_distribution.sh
vendored
@@ -798,6 +798,18 @@ mra_files() {
|
||||
}
|
||||
|
||||
game_folders() {
|
||||
local TMP_FOLDER="${1}"
|
||||
for folder in $(game_folders_from_conf_str "${TMP_FOLDER}") ; do
|
||||
echo "${folder}"
|
||||
for file in $(files_with_no_date "${TMP_FOLDER}/releases") ; do
|
||||
if is_mgl_file "${file}" ; then
|
||||
extract_from_setname_tag "${file}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
game_folders_from_conf_str() {
|
||||
local FOLDER="${1}"
|
||||
pushd "${FOLDER}" > /dev/null 2>&1
|
||||
extract_from_conf_str "localparam"
|
||||
@@ -805,6 +817,7 @@ game_folders() {
|
||||
popd > /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
extract_from_conf_str() {
|
||||
local PARAMETER="${1}"
|
||||
for conf_line in $(grep -H * -e "\s*${PARAMETER}\s\s*CONF_STR1\{0,1\}\s*=" 2> /dev/null) ; do
|
||||
@@ -819,6 +832,23 @@ extract_from_conf_str() {
|
||||
done
|
||||
}
|
||||
|
||||
extract_from_setname_tag() {
|
||||
local FILE="${1}"
|
||||
source <(python3 -c "
|
||||
import xml.etree.ElementTree as ET
|
||||
try:
|
||||
context = ET.iterparse('${FILE}', events=('start',))
|
||||
for _, elem in context:
|
||||
elem_tag = elem.tag.lower()
|
||||
if elem_tag == 'setname':
|
||||
if elem.text is None:
|
||||
continue
|
||||
print('echo %s' % elem.text.strip())
|
||||
except ET.ParseError as e:
|
||||
pass
|
||||
")
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
|
||||
update_distribution "${1}" "${2:-}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user