From fb3212fd1a997c8f0176415f67899ae790843eec Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 15 May 2020 18:29:39 +0200 Subject: [PATCH] python: show example names colored when possible --- bindings/python/example.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bindings/python/example.py b/bindings/python/example.py index 9ffd4be..6302f39 100755 --- a/bindings/python/example.py +++ b/bindings/python/example.py @@ -18,6 +18,8 @@ except ImportError: def name_hashes(): + print_example_name("name_hashes examples") + path = "/chr/c0000.anibnd.dcx" hash_u32 = pyironring.name_hashes.hash(path) print('Hash for path "{}" is {:X}'.format(path, hash_u32)) @@ -30,7 +32,15 @@ def name_hashes(): try: pyironring.name_hashes.load_name_map("nonexistent.txt") except FileNotFoundError: - print("Received FileNotFoundError exception.") + print("Received expected FileNotFoundError exception.") + + +def print_example_name(text): + try: + import termcolor + print(termcolor.colored(text, 'blue', attrs=['bold'])) + except ImportError: + print(text) if __name__ == "__main__":