diff options
author | Jesusaves <cpntb1@ymail.com> | 2022-10-24 10:49:16 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2022-10-24 10:49:16 -0300 |
commit | 1dbac488c2018f9fcc5c677fecbc81f47bda6920 (patch) | |
tree | b017f8aac4d90d3bb9a8879e9a901d623c4c33a0 /merge-client.py | |
parent | c83a17446c9ffd7f78ac748b75ce13dd8dd60967 (diff) | |
download | tools-1dbac488c2018f9fcc5c677fecbc81f47bda6920.tar.gz tools-1dbac488c2018f9fcc5c677fecbc81f47bda6920.tar.bz2 tools-1dbac488c2018f9fcc5c677fecbc81f47bda6920.tar.xz tools-1dbac488c2018f9fcc5c677fecbc81f47bda6920.zip |
Recursion for XML subfiles
Diffstat (limited to 'merge-client.py')
-rwxr-xr-x | merge-client.py | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/merge-client.py b/merge-client.py index 45cf149..10c8083 100755 --- a/merge-client.py +++ b/merge-client.py @@ -25,20 +25,41 @@ def fix_id(l, offset): l="\"".join(tmp) return l -def hp(l): +def hp(l, WHERE): global paths if "<include" in l: return if ".png" in l or ".ogg" in l or ".xml" in l: tmpi=l.split("\"") + if len(tmpi) == 1: + tmpi=l.split("sprite") for e in tmpi: + e=e.replace(">", "").replace("<", "") + if e.endswith("/"): + e=e[:-1] if e.endswith(".png"): paths.append(e) elif e.endswith(".ogg"): paths.append(e) elif e.endswith(".xml"): - ## TODO: We must also open the XML and extract paths from it paths.append(e) + + ## We must also open the XML and extract paths from it + + pt="NO PATH FOUND" + if os.path.exists("%s/%s" % (WHERE, e)): + pt = "%s/%s" % (WHERE, e) + elif os.path.exists("%s/graphics/sprites/%s" % (WHERE, e)): + pt = "%s/graphics/sprites/%s" % (WHERE, e) + elif os.path.exists("%s/graphics/%s" % (WHERE, e)): + pt = "%s/graphics/%s" % (WHERE, e) + + with open(pt, 'r') as j: + for k in j: + i=k.split("\"") + for n in i: + if n.endswith(".png"): + paths.append(n) return def unify(YESELF): @@ -119,12 +140,12 @@ with open("%s/items.xml" % MOUBOO, "r") as f: continue if "</items>" in j: break - hp(j) + hp(j, MOUBOO) item_db.append(j) continue ## Save the line - hp(l) + hp(l, MOUBOO) item_db.append(l) while not "</items>" in item_db[-1]: item_db=item_db[:-1] @@ -161,7 +182,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f: break j=fix_id(j, 10000) item_db.append(j) - hp(j) + hp(j, EVOLVED) continue ## Save the line @@ -170,7 +191,7 @@ with open("%s/items.xml" % EVOLVED, "r") as f: saving=True continue item_db.append(l) - hp(l) + hp(l, EVOLVED) while not "</items>" in item_db[-1]: item_db=item_db[:-1] item_db=item_db[:-1] @@ -207,7 +228,7 @@ with open("%s/items.xml" % REVOLT, "r") as f: break j=fix_id(j, 10000) item_db.append(j) - hp(j) + hp(j, REVOLT) continue ## Save the line @@ -216,7 +237,7 @@ with open("%s/items.xml" % REVOLT, "r") as f: saving=True continue item_db.append(l) - hp(l) + hp(l, REVOLT) while not "</items>" in item_db[-1]: item_db=item_db[:-1] #item_db=item_db[:-1] |