From ac53811e01026794f6624f0c4d211f666a974228 Mon Sep 17 00:00:00 2001 From: Jeff S Date: Sat, 5 Mar 2022 04:11:02 +0000 Subject: [PATCH] Add from_script classmethod to get ScriptExpression by name --- src/urtypes/crypto/output.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/urtypes/crypto/output.py b/src/urtypes/crypto/output.py index 4126e5a..62a5e7c 100644 --- a/src/urtypes/crypto/output.py +++ b/src/urtypes/crypto/output.py @@ -36,6 +36,13 @@ def __init__(self, tag, expression): def __eq__(self, o): return self.tag == o.tag and self.expression == o.expression + @classmethod + def from_script(cls, script): + for script_expression in SCRIPT_EXPRESSION_TAG_MAP.values(): + if script == script_expression.expression: + return script_expression + raise ValueError("unknown script") + SCRIPT_EXPRESSION_TAG_MAP = { 307: ScriptExpression(307, "addr"),