mirror of
https://github.com/zeldaret/oot.git
synced 2025-05-11 03:23:46 +00:00
fix optional rich usage
This commit is contained in:
parent
e5cc601482
commit
5861158d64
1 changed files with 15 additions and 11 deletions
|
@ -19,6 +19,15 @@ from .extase.memorymap import MemoryContext
|
||||||
|
|
||||||
from . import z64_resource_handlers
|
from . import z64_resource_handlers
|
||||||
|
|
||||||
|
try:
|
||||||
|
import rich
|
||||||
|
import rich.console
|
||||||
|
import rich.pretty
|
||||||
|
except ImportError:
|
||||||
|
USE_RICH = False
|
||||||
|
else:
|
||||||
|
USE_RICH = True
|
||||||
|
|
||||||
#
|
#
|
||||||
# main
|
# main
|
||||||
#
|
#
|
||||||
|
@ -104,11 +113,9 @@ def process_pool(
|
||||||
if VERBOSE1:
|
if VERBOSE1:
|
||||||
print("> process_pool")
|
print("> process_pool")
|
||||||
colls_str = " + ".join(set(map(str, (_c.out_path for _c in pool_desc.collections))))
|
colls_str = " + ".join(set(map(str, (_c.out_path for _c in pool_desc.collections))))
|
||||||
try:
|
if USE_RICH:
|
||||||
import rich
|
|
||||||
|
|
||||||
rich.print(f"[b]{colls_str}[/b]")
|
rich.print(f"[b]{colls_str}[/b]")
|
||||||
except ImportError:
|
else:
|
||||||
print(colls_str)
|
print(colls_str)
|
||||||
|
|
||||||
file_by_rescoll: dict[ResourcesDescCollection, File] = dict()
|
file_by_rescoll: dict[ResourcesDescCollection, File] = dict()
|
||||||
|
@ -485,13 +492,7 @@ def main():
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
if USE_RICH:
|
||||||
import rich.pretty
|
|
||||||
import rich.console
|
|
||||||
except ImportError:
|
|
||||||
traceback.print_exc(file=sys.stdout)
|
|
||||||
print("Install rich for prettier output (`pip install rich`)")
|
|
||||||
else:
|
|
||||||
rich.console.Console().print_exception()
|
rich.console.Console().print_exception()
|
||||||
# TODO implement more __rich_repr__
|
# TODO implement more __rich_repr__
|
||||||
if e.__class__ in (Exception, AssertionError, NotImplementedError):
|
if e.__class__ in (Exception, AssertionError, NotImplementedError):
|
||||||
|
@ -500,6 +501,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
print("rich.pretty.pprint(e):")
|
print("rich.pretty.pprint(e):")
|
||||||
rich.pretty.pprint(e, indent_guides=False)
|
rich.pretty.pprint(e, indent_guides=False)
|
||||||
|
else:
|
||||||
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
print("Install rich for prettier output (`pip install rich`)")
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Reference in a new issue