1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-24 16:01:26 +00:00

slightly improve standard output

This commit is contained in:
Dragorn421 2025-02-08 18:10:57 +01:00
parent 8ef1c164a4
commit 3a428239c9
No known key found for this signature in database
GPG key ID: 381AEBAF3D429335
4 changed files with 46 additions and 49 deletions

View file

@ -16,7 +16,7 @@ if TYPE_CHECKING:
# 0: nothing, 1: in progress & waiting, 2: all # 0: nothing, 1: in progress & waiting, 2: all
VERBOSE_FILE_TRY_PARSE_DATA = 0 VERBOSE_FILE_TRY_PARSE_DATA = 0
VERBOSE_REPORT_RESBUF = True VERBOSE_REPORT_RESBUF = False
# #
# file # file
@ -263,7 +263,7 @@ class File:
else: else:
print("??? no last_parse_waiting_e ???") print("??? no last_parse_waiting_e ???")
print("then why has", resource.name, "not been parsed?") print("then why has", resource.name, "not been parsed?")
BEST_EFFORT = True # TODO move BEST_EFFORT = False # TODO move
if BEST_EFFORT: if BEST_EFFORT:
print("BEST_EFFORT: removing non-parsed resources") print("BEST_EFFORT: removing non-parsed resources")
for resource in resources_data_not_parsed: for resource in resources_data_not_parsed:

View file

@ -3,6 +3,11 @@ from dataclasses import dataclass
from typing import Callable, TypeVar, Generic from typing import Callable, TypeVar, Generic
try:
from rich.pretty import pprint as rich_pprint
except ModuleNotFoundError:
rich_pprint = print
from . import Resource, File, GetResourceAtResult from . import Resource, File, GetResourceAtResult
@ -321,18 +326,15 @@ class MemoryContext:
fake_resource.reporters.add(reporter) fake_resource.reporters.add(reporter)
fake_file.add_resource(fake_resource) fake_file.add_resource(fake_resource)
if VERBOSE_BEST_EFFORT: if VERBOSE_BEST_EFFORT:
print( print("BEST_EFFORT: ignored error e=")
"BEST_EFFORT: ignored error e=", rich_pprint(e)
repr(e), print(" on resource report by reporter=")
"on resource report by reporter=", rich_pprint(reporter)
reporter, print(f" at {address=:#08X}")
"at address=", print(" and created fake_file=")
hex(address), rich_pprint(fake_file),
"and created fake_file=", print(" and fake_resource=")
fake_file, rich_pprint(fake_resource)
"and fake_resource=",
fake_resource,
)
fake_file.FAKE_FOR_BEST_EFFORT = True fake_file.FAKE_FOR_BEST_EFFORT = True
fake_resource.FAKE_FOR_BEST_EFFORT = True fake_resource.FAKE_FOR_BEST_EFFORT = True
return fake_resource return fake_resource
@ -370,18 +372,11 @@ class MemoryContext:
except UnmappedAddressError as e: except UnmappedAddressError as e:
if BEST_EFFORT: if BEST_EFFORT:
if VERBOSE_BEST_EFFORT: if VERBOSE_BEST_EFFORT:
print( print("BEST_EFFORT: ignored error e=")
"BEST_EFFORT: ignored error e=", rich_pprint(e)
repr(e), print(" and skipping marking resource buffer for reporter=")
"and skipping marking resource buffer for reporter=", rich_pprint(reporter)
reporter, print(f" {resource_type=} {address_start=:#08X} {address_end=:#08X}")
"resource_type=",
resource_type,
"address_start=",
hex(address_start),
"address_end=",
hex(address_end),
)
return return
raise raise
file_start = resolve_result.file_offset file_start = resolve_result.file_offset
@ -401,12 +396,9 @@ class MemoryContext:
except UnmappedAddressError as e: except UnmappedAddressError as e:
if BEST_EFFORT: if BEST_EFFORT:
if VERBOSE_BEST_EFFORT: if VERBOSE_BEST_EFFORT:
print( print("BEST_EFFORT: ignored error e="),
"BEST_EFFORT: ignored error e=", rich_pprint(e)
repr(e), print(f" and returning raw address=0x{address:08X}")
"and returning raw address =",
f"0x{address:08X}",
)
return f"0x{address:08X}" return f"0x{address:08X}"
raise raise

View file

@ -1,12 +1,18 @@
from __future__ import annotations
from pathlib import Path
import enum import enum
import io
from pathlib import Path
import reprlib import reprlib
import io
from typing import TYPE_CHECKING, Union, Optional, Callable from typing import TYPE_CHECKING, Union, Optional, Callable
try:
from rich.pretty import pprint as rich_pprint
except ModuleNotFoundError:
rich_pprint = print
# pip install pygfxd@git+https://github.com/Dragorn421/pygfxd.git@065541d92ad0d84d214fad4f30e4592f7102c013
import pygfxd
if TYPE_CHECKING: if TYPE_CHECKING:
from ..extase.memorymap import MemoryContext from ..extase.memorymap import MemoryContext
@ -31,13 +37,6 @@ VERBOSE_ColorIndexedTexturesManager = False
VERBOSE_BEST_EFFORT_TLUT_NO_REAL_USER = True VERBOSE_BEST_EFFORT_TLUT_NO_REAL_USER = True
import pygfxd
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from ......pygfxd import pygfxd
class MtxResource(CDataResource): class MtxResource(CDataResource):
def write_mtx(resource, memory_context, v, f: io.TextIOBase, line_prefix): def write_mtx(resource, memory_context, v, f: io.TextIOBase, line_prefix):
assert isinstance(v, dict) assert isinstance(v, dict)
@ -301,9 +300,13 @@ class TextureResource(Resource):
cur_count = self.width * self.height cur_count = self.width * self.height
assert cur_count >= new_min_count, ( assert cur_count >= new_min_count, (
cur_count, "TLUT resource",
new_min_count,
self, self,
"is defined as having",
cur_count,
"colors, but there is an image using it as having at least",
new_min_count,
"colors:",
resource_ci, resource_ci,
) )
@ -392,9 +395,11 @@ class TextureResource(Resource):
if VERBOSE_BEST_EFFORT_TLUT_NO_REAL_USER: if VERBOSE_BEST_EFFORT_TLUT_NO_REAL_USER:
print( print(
"BEST_EFFORT", "BEST_EFFORT",
"no real (non-fake for best effort) ci resource uses this tlut\n ", "no real (non-fake for best effort) ci resource uses this tlut",
self, )
"\n extracting the tlut as its own png", rich_pprint(self)
print(
" extracting the tlut as its own png",
self.extract_to_path.resolve().as_uri(), self.extract_to_path.resolve().as_uri(),
"instead of relying on it being generated", "instead of relying on it being generated",
"\n (note while the result may build and match the tlut probably is", "\n (note while the result may build and match the tlut probably is",

View file

@ -22,7 +22,7 @@ from . import z64_resource_handlers
# #
VERBOSE1 = False VERBOSE1 = False
VERBOSE2 = True VERBOSE2 = False
# "options" # "options"
RM_SOURCE = True RM_SOURCE = True