diff options
Diffstat (limited to 'tools/arch.py')
-rw-r--r-- | tools/arch.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/arch.py b/tools/arch.py index ac2f32b..b245f38 100644 --- a/tools/arch.py +++ b/tools/arch.py @@ -45,12 +45,17 @@ class Arch( def load_from_json(json_path): """Return an Arch from a .json file.""" with open(json_path, 'r') as json_file: - constants = json.load(json_file) - return Arch( - arch_nr=constants['arch_nr'], - arch_name=constants['arch_name'], - bits=constants['bits'], - syscalls=constants['syscalls'], - constants=constants['constants'], - syscall_groups=constants.get('syscall_groups', {}), - ) + return Arch.load_from_json_bytes(json_file.read()) + + @staticmethod + def load_from_json_bytes(json_bytes): + """Return an Arch from a json string.""" + constants = json.loads(json_bytes) + return Arch( + arch_nr=constants["arch_nr"], + arch_name=constants["arch_name"], + bits=constants["bits"], + syscalls=constants["syscalls"], + constants=constants["constants"], + syscall_groups=constants.get("syscall_groups", {}), + ) |