How to use the uncompyle6.semantics.consts.TABLE_DIRECT function in uncompyle6

To help you get started, we’ve selected a few uncompyle6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocky / python-decompile3 / uncompyle6 / semantics / customize.py View on Github external
def customize_for_version(self, is_pypy, version):
    if is_pypy:
        ########################
        # PyPy changes
        #######################
        TABLE_DIRECT.update({
            'assert_pypy':	( '%|assert %c\n' , 1 ),
            'assert2_pypy':	( '%|assert %c, %c\n' , 1, 4 ),
            'try_except_pypy':	   ( '%|try:\n%+%c%-%c\n\n', 1, 2 ),
            'tryfinallystmt_pypy': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 3 ),
            'assign3_pypy':        ( '%|%c, %c, %c = %c, %c, %c\n', 5, 4, 3, 0, 1, 2 ),
            'assign2_pypy':        ( '%|%c, %c = %c, %c\n', 3, 2, 0, 1),
            })
    else:
        ########################
        # Without PyPy
        #######################
        TABLE_DIRECT.update({
            'assert':		( '%|assert %c\n' , 0 ),
            'assert2':		( '%|assert %c, %c\n' , 0, 3 ),
            'try_except':	( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
            'assign2':          ( '%|%c, %c = %c, %c\n',
github rocky / python-decompile3 / uncompyle6 / semantics / customize26_27.py View on Github external
########################################
    # Python 2.6+
    #    except  as <var>
    # vs. older:
    #    except  , <var>
    #
    # For 2.6 we use the older syntax which
    # matches how we parse this in bytecode
    ########################################
    if version &gt; 2.6:
        TABLE_DIRECT.update({
            'except_cond2':	( '%|except %c as %c:\n', 1, 5 ),
        })
    else:
        TABLE_DIRECT.update({
            'testtrue_then': ( 'not %p', (0, 22) ),
</var></var>
github rocky / python-uncompyle6 / uncompyle6 / semantics / pysource.py View on Github external
'raise_stmt2':	 ( '%|raise %c from %c\n', 0, 1),
            })

            if version &gt;= 3.2:
                TABLE_DIRECT.update({
                'del_deref_stmt': ( '%|del %c\n', 0),
                'DELETE_DEREF': ( '%{pattr}', 0 ),
                })

        if version &lt;= 2.4:
            TABLE_DIRECT.update({
                'importmultiple': ( '%|import %c%c\n', 2, 3),
                'import_cont'   : ( ', %c', 2),
                })
            if version == 2.3:
                TABLE_DIRECT.update({
                    'if1_stmt':	( '%|if 1\n%+%c%-', 5 )
                })

            global NAME_MODULE
            NAME_MODULE = AST('stmt',
                              [ AST('assign',
                                    [ AST('expr',
                                          [Token('LOAD_GLOBAL', pattr='__name__',
                                                 offset=0, has_arg=True)]),
                                      AST('store',
                                          [ Token('STORE_NAME', pattr='__module__',
                                                  offset=3, has_arg=True)])
                                    ])])
            pass
            if version &lt;= 2.3:
                TABLE_DIRECT.update({
github rocky / python-uncompyle6 / uncompyle6 / semantics / customize.py View on Github external
def customize_for_version(self, is_pypy, version):
    if is_pypy:
        ########################
        # PyPy changes
        #######################
        TABLE_DIRECT.update({
            'assert_pypy':	( '%|assert %c\n' ,     (1, 'assert_expr') ),
            # This is as a result of an if transoration
            'assert0_pypy':	( '%|assert %c\n' ,     (0, 'assert_expr') ),

            'assert_not_pypy':	( '%|assert not %c\n' , (1, 'assert_exp') ),
            'assert2_not_pypy':	( '%|assert not %c, %c\n' , (1, 'assert_exp'),
                                  (4, 'expr') ),
            'assert2_pypy':	( '%|assert %c, %c\n' , (1, 'assert_expr'),
                                  (4, 'expr') ),
            'try_except_pypy':	   ( '%|try:\n%+%c%-%c\n\n', 1, 2 ),
            'tryfinallystmt_pypy': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 3 ),
            'assign3_pypy':        ( '%|%c, %c, %c = %c, %c, %c\n', 5, 4, 3, 0, 1, 2 ),
            'assign2_pypy':        ( '%|%c, %c = %c, %c\n', 3, 2, 0, 1),
            })
    else:
        ########################
github rocky / python-decompile3 / uncompyle6 / semantics / customize26_27.py View on Github external
def customize_for_version26_27(self, version):

    ########################################
    # Python 2.6+
    #    except  as <var>
    # vs. older:
    #    except  , <var>
    #
    # For 2.6 we use the older syntax which
    # matches how we parse this in bytecode
    ########################################
    if version &gt; 2.6:
        TABLE_DIRECT.update({
            'except_cond2':	( '%|except %c as %c:\n', 1, 5 ),
        })
    else:
        TABLE_DIRECT.update({
            'testtrue_then': ( 'not %p', (0, 22) ),
</var></var>
github rocky / python-uncompyle6 / uncompyle6 / semantics / customize.py View on Github external
(0, PRECEDENCE['unary_not']), 3 ),

            "assign2": ("%|%c, %c = %c, %c\n", 3, 4, 0, 1),
            "assign3": ("%|%c, %c, %c = %c, %c, %c\n", 5, 6, 7, 0, 1, 2),
            "try_except": ("%|try:\n%+%c%-%c\n\n", 1, 3),
        })
    if version &gt;= 3.0:
        if version &gt;= 3.2:
            TABLE_DIRECT.update(
                {"del_deref_stmt": ("%|del %c\n", 0), "DELETE_DEREF": ("%{pattr}", 0)}
            )
        from uncompyle6.semantics.customize3 import customize_for_version3

        customize_for_version3(self, version)
    else:  # &lt; 3.0
        TABLE_DIRECT.update(
            {"except_cond3": ("%|except %c, %c:\n", (1, "expr"), (-2, "store"))}
        )
        if version &lt;= 2.6:
            TABLE_DIRECT["testtrue_then"] = TABLE_DIRECT["testtrue"]

        if 2.4 &lt;= version &lt;= 2.6:
            TABLE_DIRECT.update({"comp_for": (" for %c in %c", 3, 1)})
        else:
            TABLE_DIRECT.update({"comp_for": (" for %c in %c%c", 2, 0, 3)})

        if version &gt;= 2.5:
            from uncompyle6.semantics.customize25 import customize_for_version25

            customize_for_version25(self, version)

            if version &gt;= 2.6:
github rocky / python-uncompyle6 / uncompyle6 / semantics / fragments.py View on Github external
compile_mode=compile_mode, is_pypy=is_pypy)

        # hide_internal suppresses displaying the additional instructions that sometimes
        # exist in code but but were not written in the source code.
        # An example is:
        # __module__ = __name__
        # If showing source code we generally don't want to show this. However in fragment
        # deparsing we generally do need to see these instructions since we may be stopped
        # at one. So here we do not want to suppress showing such instructions.
        self.hide_internal = False
        self.offsets = {}
        self.last_finish = -1

        # FIXME: is there a better way?
        global MAP_DIRECT_FRAGMENT
        MAP_DIRECT_FRAGMENT = dict(TABLE_DIRECT, **TABLE_DIRECT_FRAGMENT),
github rocky / python-decompile3 / uncompyle6 / semantics / customize.py View on Github external
})
    else:
        ########################
        # Without PyPy
        #######################
        TABLE_DIRECT.update({
            'assert':		( '%|assert %c\n' , 0 ),
            'assert2':		( '%|assert %c, %c\n' , 0, 3 ),
            'try_except':	( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
            'assign2':          ( '%|%c, %c = %c, %c\n',
                                  3, 4, 0, 1 ),
            'assign3':          ( '%|%c, %c, %c = %c, %c, %c\n',
                                  5, 6, 7, 0, 1, 2 ),
            })
    if  version &gt;= 3.0:
        TABLE_DIRECT.update({
            # Gotta love Python for its futzing around with syntax like this
            'raise_stmt2':	 ( '%|raise %c from %c\n', 0, 1),
        })

        if version &gt;= 3.2:
            TABLE_DIRECT.update({
            'del_deref_stmt': ( '%|del %c\n', 0),
            'DELETE_DEREF': ( '%{pattr}', 0 ),
            })
        from uncompyle6.semantics.customize3 import customize_for_version3
        customize_for_version3(self, version)
    else:  # &lt; 3.0
        if 2.4 &lt;= version &lt;= 2.6:
            TABLE_DIRECT.update({
                'comp_for':	( ' for %c in %c', 3, 1 ),
            })
github rocky / python-uncompyle6 / uncompyle6 / semantics / customize3.py View on Github external
TABLE_DIRECT.update(
        {
            "tryelsestmtl3": (
                "%|try:\n%+%c%-%c%|else:\n%+%c%-",
                (1, "suite_stmts_opt"),
                (3, "except_handler"),
                (5, "else_suitel"),
            ),
            "LOAD_CLASSDEREF": ("%{pattr}",),
        }
    )
    if version >= 3.4:
        #######################
        # Python 3.4+ Changes #
        #######################
        TABLE_DIRECT.update(
            {
                "LOAD_CLASSDEREF": ("%{pattr}",),
                "yield_from": ("yield from %c", (0, "expr")),
            }
        )
        if version >= 3.5:
            customize_for_version35(self, version)
            if version >= 3.6:
                customize_for_version36(self, version)
                if version >= 3.7:
                    customize_for_version37(self, version)
                    if version >= 3.8:
                        customize_for_version38(self, version)
                        pass  # version >= 3.8
                    pass  # 3.7
                pass  # 3.6
github rocky / python-uncompyle6 / uncompyle6 / semantics / pysource.py View on Github external
def customize_for_version(self, is_pypy, version):
        if is_pypy:
            ########################
            # PyPy changes
            #######################
            TABLE_DIRECT.update({
                'assert_pypy':	( '%|assert %c\n' , 1 ),
                'assert2_pypy':	( '%|assert %c, %c\n' , 1, 4 ),
                'try_except_pypy':	   ( '%|try:\n%+%c%-%c\n\n', 1, 2 ),
                'tryfinallystmt_pypy': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', 1, 3 ),
                'assign3_pypy':        ( '%|%c, %c, %c = %c, %c, %c\n', 5, 4, 3, 0, 1, 2 ),
                'assign2_pypy':        ( '%|%c, %c = %c, %c\n', 3, 2, 0, 1),
                })
        else:
            ########################
            # Without PyPy
            #######################
            TABLE_DIRECT.update({
                'assert':		( '%|assert %c\n' , 0 ),
                'assert2':		( '%|assert %c, %c\n' , 0, 3 ),
                'try_except':	( '%|try:\n%+%c%-%c\n\n', 1, 3 ),
                'assign2':      ( '%|%c, %c = %c, %c\n', 3, 4, 0, 1 ),