1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-11 03:23:46 +00:00

misc cleanup/fixes, pygfxd 1.0.3

This commit is contained in:
Dragorn421 2025-02-10 22:30:22 +01:00
parent 15692565fe
commit 8e5e543731
No known key found for this signature in database
GPG key ID: 381AEBAF3D429335
7 changed files with 36 additions and 22 deletions

View file

@ -6,3 +6,9 @@ For details on the xml files contents, see [the assets xml specification file](.
The extraction tool can use [rich](https://github.com/Textualize/rich) if installed to make output prettier.
If you are looking at output or errors from during extraction, consider installing rich for a better experience: `.venv/bin/python3 -m pip install rich`
To run the extraction outside of `make setup`, use `./tools/extract_assets.sh VERSION`.
- Pass `-f` to force extraction: otherwise only assets for which xmls were modified will be extracted.
- Pass `-j` to use multiprocessing, making extraction quicker. Note that this makes for less readable errors if any error happens.
- Pass `-s name` to extract assets using baserom file `name`.
- Pass `-r -s 'name.*'` to extract assets using baserom files whose name match regular expression `name.*`.

View file

@ -2,6 +2,7 @@
crunch64>=0.5.1,<1.0.0
ipl3checksum>=1.2.0,<2.0.0
pyyaml>=6.0.1,<7.0.0
pygfxd>=1.0.3,<2.0.0
# asm-differ
argcomplete

View file

@ -1,3 +1,10 @@
from pprint import pprint as vanilla_pprint
try:
from rich.pretty import pprint
except ImportError:
pprint = vanilla_pprint
from tools import version_config
from . import base
@ -8,16 +15,15 @@ def main():
pools = base.get_resources_desc(vc)
from pprint import pprint
if 0:
with open(
"/home/dragorn421/Documents/oot/tools/assets/descriptor/resources.txt",
"w",
) as f:
for i, pool in enumerate(pools):
print(round(i / len(pools) * 100, 2), "%", end="\r")
pprint(pool, f)
try:
for pool in pools:
if any(coll.out_path.name == "gameplay_keep" for coll in pool.collections):
vanilla_pprint(pool)
else:
pprint(pool)
input("Press enter for next pool")
except KeyboardInterrupt:
print()
main()

View file

@ -191,14 +191,6 @@ def get_resources_desc(vc: version_config.VersionConfig):
except Exception as e:
raise Exception(f"Error with pool {pool}") from e
if 0:
from rich.pretty import pretty_repr
with Path(
"/home/dragorn421/Documents/oot/tools/assets/descriptor/pools.txt"
).open("w") as f:
f.write(pretty_repr(pools))
return pools

View file

@ -5,6 +5,6 @@ if __name__ == "__main__":
if profile:
import cProfile
cProfile.run("extract_xml_z64.main()", "cprof_assets421.txt")
cProfile.run("extract_xml_z64.main()", "cprofile_extract_assets.txt")
else:
extract_xml_z64.main()

View file

@ -760,7 +760,9 @@ class Resource(abc.ABC):
range_end: Optional[int],
name: str,
):
assert 0 <= range_start < file.size
assert (
0 <= range_start < file.size
), f"{range_start=:#08X} out of range [0,{file.size=:#08X})"
if range_end is None:
assert self.can_size_be_unknown
else:

View file

@ -65,6 +65,10 @@ def create_file_resources(rescoll: ResourcesDescCollection, file: File):
) as e:
resource = e.resource
list_ResourceNeedsPostProcessWithPoolResourcesException.append(e)
except Exception as e:
raise Exception(
"Error while creating resource from description:", resource_desc
) from e
# TODO nice hack right here.
# probably instead rework the "c declaration" system into a more opaque object
@ -454,13 +458,14 @@ def main():
import traceback
import sys
traceback.print_exc(file=sys.stdout)
try:
import rich.pretty
import rich.console
except:
traceback.print_exc(file=sys.stdout)
print("Install rich for prettier output (`pip install rich`)")
else:
rich.console.Console().print_exception()
# TODO implement more __rich_repr__
if e.__class__ in (Exception, AssertionError, NotImplementedError):
print("rich.pretty.pprint(e.args):")
@ -468,6 +473,8 @@ def main():
else:
print("rich.pretty.pprint(e):")
rich.pretty.pprint(e, indent_guides=False)
sys.exit(1)
finally:
with last_extracts_json_p.open("w") as f:
json.dump(last_extracts, f)