partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Backend.dedup_alert
Update alert status, service, value, text, timeout and rawData, increment duplicate count and set repeat=True, and keep track of last receive id and time but don't append to history unless status changes.
alerta/database/backends/postgres/base.py
def dedup_alert(self, alert, history): """ Update alert status, service, value, text, timeout and rawData, increment duplicate count and set repeat=True, and keep track of last receive id and time but don't append to history unless status changes. """ alert.history = history ...
def dedup_alert(self, alert, history): """ Update alert status, service, value, text, timeout and rawData, increment duplicate count and set repeat=True, and keep track of last receive id and time but don't append to history unless status changes. """ alert.history = history ...
[ "Update", "alert", "status", "service", "value", "text", "timeout", "and", "rawData", "increment", "duplicate", "count", "and", "set", "repeat", "=", "True", "and", "keep", "track", "of", "last", "receive", "id", "and", "time", "but", "don", "t", "append", ...
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L202-L226
[ "def", "dedup_alert", "(", "self", ",", "alert", ",", "history", ")", ":", "alert", ".", "history", "=", "history", "update", "=", "\"\"\"\n UPDATE alerts\n SET status=%(status)s, service=%(service)s, value=%(value)s, text=%(text)s,\n time...
6478d6addc217c96a4a6688fab841035bef134e1
train
Backend._insert
Insert, with return.
alerta/database/backends/postgres/base.py
def _insert(self, query, vars): """ Insert, with return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchone()
def _insert(self, query, vars): """ Insert, with return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchone()
[ "Insert", "with", "return", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L1262-L1270
[ "def", "_insert", "(", "self", ",", "query", ",", "vars", ")", ":", "cursor", "=", "self", ".", "get_db", "(", ")", ".", "cursor", "(", ")", "self", ".", "_log", "(", "cursor", ",", "query", ",", "vars", ")", "cursor", ".", "execute", "(", "query...
6478d6addc217c96a4a6688fab841035bef134e1
train
Backend._fetchone
Return none or one row.
alerta/database/backends/postgres/base.py
def _fetchone(self, query, vars): """ Return none or one row. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) return cursor.fetchone()
def _fetchone(self, query, vars): """ Return none or one row. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) return cursor.fetchone()
[ "Return", "none", "or", "one", "row", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L1272-L1279
[ "def", "_fetchone", "(", "self", ",", "query", ",", "vars", ")", ":", "cursor", "=", "self", ".", "get_db", "(", ")", ".", "cursor", "(", ")", "self", ".", "_log", "(", "cursor", ",", "query", ",", "vars", ")", "cursor", ".", "execute", "(", "que...
6478d6addc217c96a4a6688fab841035bef134e1
train
Backend._fetchall
Return multiple rows.
alerta/database/backends/postgres/base.py
def _fetchall(self, query, vars, limit=None, offset=0): """ Return multiple rows. """ if limit is None: limit = current_app.config['DEFAULT_PAGE_SIZE'] query += ' LIMIT %s OFFSET %s''' % (limit, offset) cursor = self.get_db().cursor() self._log(cursor,...
def _fetchall(self, query, vars, limit=None, offset=0): """ Return multiple rows. """ if limit is None: limit = current_app.config['DEFAULT_PAGE_SIZE'] query += ' LIMIT %s OFFSET %s''' % (limit, offset) cursor = self.get_db().cursor() self._log(cursor,...
[ "Return", "multiple", "rows", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L1281-L1291
[ "def", "_fetchall", "(", "self", ",", "query", ",", "vars", ",", "limit", "=", "None", ",", "offset", "=", "0", ")", ":", "if", "limit", "is", "None", ":", "limit", "=", "current_app", ".", "config", "[", "'DEFAULT_PAGE_SIZE'", "]", "query", "+=", "'...
6478d6addc217c96a4a6688fab841035bef134e1
train
Backend._updateone
Update, with optional return.
alerta/database/backends/postgres/base.py
def _updateone(self, query, vars, returning=False): """ Update, with optional return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchone() if returning else None
def _updateone(self, query, vars, returning=False): """ Update, with optional return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchone() if returning else None
[ "Update", "with", "optional", "return", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L1293-L1301
[ "def", "_updateone", "(", "self", ",", "query", ",", "vars", ",", "returning", "=", "False", ")", ":", "cursor", "=", "self", ".", "get_db", "(", ")", ".", "cursor", "(", ")", "self", ".", "_log", "(", "cursor", ",", "query", ",", "vars", ")", "c...
6478d6addc217c96a4a6688fab841035bef134e1
train
Backend._updateall
Update, with optional return.
alerta/database/backends/postgres/base.py
def _updateall(self, query, vars, returning=False): """ Update, with optional return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchall() if returning else None
def _updateall(self, query, vars, returning=False): """ Update, with optional return. """ cursor = self.get_db().cursor() self._log(cursor, query, vars) cursor.execute(query, vars) self.get_db().commit() return cursor.fetchall() if returning else None
[ "Update", "with", "optional", "return", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/database/backends/postgres/base.py#L1303-L1311
[ "def", "_updateall", "(", "self", ",", "query", ",", "vars", ",", "returning", "=", "False", ")", ":", "cursor", "=", "self", ".", "get_db", "(", ")", ".", "cursor", "(", ")", "self", ".", "_log", "(", "cursor", ",", "query", ",", "vars", ")", "c...
6478d6addc217c96a4a6688fab841035bef134e1
train
Permission.is_in_scope
Return True if wanted scope is in list of scopes or derived scopes. :param want_scope: scope wanted for permission to do something (str because could be invalid scope) :param have_scopes: list of valid scopes that user has been assigned
alerta/models/permission.py
def is_in_scope(cls, want_scope: str, have_scopes: List[Scope]) -> bool: """Return True if wanted scope is in list of scopes or derived scopes. :param want_scope: scope wanted for permission to do something (str because could be invalid scope) :param have_scopes: list of valid scopes that user ...
def is_in_scope(cls, want_scope: str, have_scopes: List[Scope]) -> bool: """Return True if wanted scope is in list of scopes or derived scopes. :param want_scope: scope wanted for permission to do something (str because could be invalid scope) :param have_scopes: list of valid scopes that user ...
[ "Return", "True", "if", "wanted", "scope", "is", "in", "list", "of", "scopes", "or", "derived", "scopes", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/permission.py#L84-L99
[ "def", "is_in_scope", "(", "cls", ",", "want_scope", ":", "str", ",", "have_scopes", ":", "List", "[", "Scope", "]", ")", "->", "bool", ":", "if", "not", "want_scope", ":", "return", "True", "if", "want_scope", "in", "have_scopes", "or", "want_scope", "....
6478d6addc217c96a4a6688fab841035bef134e1
train
merge
Merge two dictionaries. :param dict1: :param dict2: :return:
alerta/utils/collections.py
def merge(dict1, dict2): """ Merge two dictionaries. :param dict1: :param dict2: :return: """ for k in dict2: if k in dict1 and isinstance(dict1[k], dict) and isinstance(dict2[k], dict): merge(dict1[k], dict2[k]) else: dict1[k] = dict2[k]
def merge(dict1, dict2): """ Merge two dictionaries. :param dict1: :param dict2: :return: """ for k in dict2: if k in dict1 and isinstance(dict1[k], dict) and isinstance(dict2[k], dict): merge(dict1[k], dict2[k]) else: dict1[k] = dict2[k]
[ "Merge", "two", "dictionaries", ".", ":", "param", "dict1", ":", ":", "param", "dict2", ":", ":", "return", ":" ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/utils/collections.py#L2-L13
[ "def", "merge", "(", "dict1", ",", "dict2", ")", ":", "for", "k", "in", "dict2", ":", "if", "k", "in", "dict1", "and", "isinstance", "(", "dict1", "[", "k", "]", ",", "dict", ")", "and", "isinstance", "(", "dict2", "[", "k", "]", ",", "dict", "...
6478d6addc217c96a4a6688fab841035bef134e1
train
Scope.from_str
Return a scope based on the supplied action and resource. :param action: the scope action eg. read, write or admin :param resource: the specific resource of the scope, if any eg. alerts, blackouts, heartbeats, users, perms, customers, keys, webhooks, oembed, management or userin...
alerta/models/enums.py
def from_str(action: str, resource: str=None): """Return a scope based on the supplied action and resource. :param action: the scope action eg. read, write or admin :param resource: the specific resource of the scope, if any eg. alerts, blackouts, heartbeats, users, perms, customers...
def from_str(action: str, resource: str=None): """Return a scope based on the supplied action and resource. :param action: the scope action eg. read, write or admin :param resource: the specific resource of the scope, if any eg. alerts, blackouts, heartbeats, users, perms, customers...
[ "Return", "a", "scope", "based", "on", "the", "supplied", "action", "and", "resource", "." ]
alerta/alerta
python
https://github.com/alerta/alerta/blob/6478d6addc217c96a4a6688fab841035bef134e1/alerta/models/enums.py#L47-L59
[ "def", "from_str", "(", "action", ":", "str", ",", "resource", ":", "str", "=", "None", ")", ":", "if", "resource", ":", "return", "Scope", "(", "'{}:{}'", ".", "format", "(", "action", ",", "resource", ")", ")", "else", ":", "return", "Scope", "(", ...
6478d6addc217c96a4a6688fab841035bef134e1
train
code_deparse
ingests and deparses a given code block 'co'. If version is None, we will use the current Python interpreter version.
uncompyle6/semantics/pysource.py
def code_deparse(co, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', is_pypy=IS_PYPY, walker=SourceWalker): """ ingests and deparses a given code block 'co'. If version is None, we will use the current Python interpreter version. """ ...
def code_deparse(co, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', is_pypy=IS_PYPY, walker=SourceWalker): """ ingests and deparses a given code block 'co'. If version is None, we will use the current Python interpreter version. """ ...
[ "ingests", "and", "deparses", "a", "given", "code", "block", "co", ".", "If", "version", "is", "None", "we", "will", "use", "the", "current", "Python", "interpreter", "version", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L2268-L2344
[ "def", "code_deparse", "(", "co", ",", "out", "=", "sys", ".", "stdout", ",", "version", "=", "None", ",", "debug_opts", "=", "DEFAULT_DEBUG_OPTS", ",", "code_objects", "=", "{", "}", ",", "compile_mode", "=", "'exec'", ",", "is_pypy", "=", "IS_PYPY", ",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
deparse_code2str
Return the deparsed text for a Python code object. `out` is where any intermediate output for assembly or tree output will be sent.
uncompyle6/semantics/pysource.py
def deparse_code2str(code, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', is_pypy=IS_PYPY, walker=SourceWalker): """Return the deparsed text for a Python code object. `out` is where any intermediate ...
def deparse_code2str(code, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', is_pypy=IS_PYPY, walker=SourceWalker): """Return the deparsed text for a Python code object. `out` is where any intermediate ...
[ "Return", "the", "deparsed", "text", "for", "a", "Python", "code", "object", ".", "out", "is", "where", "any", "intermediate", "output", "for", "assembly", "or", "tree", "output", "will", "be", "sent", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L2346-L2356
[ "def", "deparse_code2str", "(", "code", ",", "out", "=", "sys", ".", "stdout", ",", "version", "=", "None", ",", "debug_opts", "=", "DEFAULT_DEBUG_OPTS", ",", "code_objects", "=", "{", "}", ",", "compile_mode", "=", "'exec'", ",", "is_pypy", "=", "IS_PYPY"...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.pp_tuple
Pretty print a tuple
uncompyle6/semantics/pysource.py
def pp_tuple(self, tup): """Pretty print a tuple""" last_line = self.f.getvalue().split("\n")[-1] l = len(last_line)+1 indent = ' ' * l self.write('(') sep = '' for item in tup: self.write(sep) l += len(sep) s = repr(item) ...
def pp_tuple(self, tup): """Pretty print a tuple""" last_line = self.f.getvalue().split("\n")[-1] l = len(last_line)+1 indent = ' ' * l self.write('(') sep = '' for item in tup: self.write(sep) l += len(sep) s = repr(item) ...
[ "Pretty", "print", "a", "tuple" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L541-L564
[ "def", "pp_tuple", "(", "self", ",", "tup", ")", ":", "last_line", "=", "self", ".", "f", ".", "getvalue", "(", ")", ".", "split", "(", "\"\\n\"", ")", "[", "-", "1", "]", "l", "=", "len", "(", "last_line", ")", "+", "1", "indent", "=", "' '", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.n_exec_stmt
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT
uncompyle6/semantics/pysource.py
def n_exec_stmt(self, node): """ exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT """ self.write(self.indent, 'exec ') self.preorder(node[0]) if not node[1][0].isNone(): sep = ' in ' for subnode in node[1]...
def n_exec_stmt(self, node): """ exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT """ self.write(self.indent, 'exec ') self.preorder(node[0]) if not node[1][0].isNone(): sep = ' in ' for subnode in node[1]...
[ "exec_stmt", "::", "=", "expr", "exprlist", "DUP_TOP", "EXEC_STMT", "exec_stmt", "::", "=", "expr", "exprlist", "EXEC_STMT" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L625-L638
[ "def", "n_exec_stmt", "(", "self", ",", "node", ")", ":", "self", ".", "write", "(", "self", ".", "indent", ",", "'exec '", ")", "self", ".", "preorder", "(", "node", "[", "0", "]", ")", "if", "not", "node", "[", "1", "]", "[", "0", "]", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.n_list_comp
List comprehensions
uncompyle6/semantics/pysource.py
def n_list_comp(self, node): """List comprehensions""" p = self.prec self.prec = 100 if self.version >= 2.7: if self.is_pypy: self.n_list_comp_pypy27(node) return n = node[-1] elif node[-1] == 'del_stmt': if node...
def n_list_comp(self, node): """List comprehensions""" p = self.prec self.prec = 100 if self.version >= 2.7: if self.is_pypy: self.n_list_comp_pypy27(node) return n = node[-1] elif node[-1] == 'del_stmt': if node...
[ "List", "comprehensions" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L835-L892
[ "def", "n_list_comp", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "100", "if", "self", ".", "version", ">=", "2.7", ":", "if", "self", ".", "is_pypy", ":", "self", ".", "n_list_comp_pypy27", "(", "no...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.n_list_comp_pypy27
List comprehensions in PYPY.
uncompyle6/semantics/pysource.py
def n_list_comp_pypy27(self, node): """List comprehensions in PYPY.""" p = self.prec self.prec = 27 if node[-1].kind == 'list_iter': n = node[-1] elif self.is_pypy and node[-1] == 'JUMP_BACK': n = node[-2] list_expr = node[1] if len(node) ...
def n_list_comp_pypy27(self, node): """List comprehensions in PYPY.""" p = self.prec self.prec = 27 if node[-1].kind == 'list_iter': n = node[-1] elif self.is_pypy and node[-1] == 'JUMP_BACK': n = node[-2] list_expr = node[1] if len(node) ...
[ "List", "comprehensions", "in", "PYPY", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L894-L938
[ "def", "n_list_comp_pypy27", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "if", "node", "[", "-", "1", "]", ".", "kind", "==", "'list_iter'", ":", "n", "=", "node", "[", "-", "1", "]", "elif...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.comprehension_walk_newer
Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions.
uncompyle6/semantics/pysource.py
def comprehension_walk_newer(self, node, iter_index, code_index=-5): """Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions. """ p = self.prec self.prec = 27 code = node[code_index].attr ...
def comprehension_walk_newer(self, node, iter_index, code_index=-5): """Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions. """ p = self.prec self.prec = 27 code = node[code_index].attr ...
[ "Non", "-", "closure", "-", "based", "comprehensions", "the", "way", "they", "are", "done", "in", "Python3", "and", "some", "Python", "2", ".", "7", ".", "Note", ":", "there", "are", "also", "other", "set", "comprehensions", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1033-L1172
[ "def", "comprehension_walk_newer", "(", "self", ",", "node", ",", "iter_index", ",", "code_index", "=", "-", "5", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "node", "[", "code_index", "]", ".", "attr", "asse...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.listcomprehension_walk2
List comprehensions the way they are done in Python 2 and sometimes in Python 3. They're more other comprehensions, e.g. set comprehensions See if we can combine code.
uncompyle6/semantics/pysource.py
def listcomprehension_walk2(self, node): """List comprehensions the way they are done in Python 2 and sometimes in Python 3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Cod...
def listcomprehension_walk2(self, node): """List comprehensions the way they are done in Python 2 and sometimes in Python 3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Cod...
[ "List", "comprehensions", "the", "way", "they", "are", "done", "in", "Python", "2", "and", "sometimes", "in", "Python", "3", ".", "They", "re", "more", "other", "comprehensions", "e", ".", "g", ".", "set", "comprehensions", "See", "if", "we", "can", "com...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1174-L1283
[ "def", "listcomprehension_walk2", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "Code", "(", "node", "[", "1", "]", ".", "attr", ",", "self", ".", "scanner", ",", "self", ".", "cur...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.setcomprehension_walk3
Set comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code.
uncompyle6/semantics/pysource.py
def setcomprehension_walk3(self, node, collection_index): """Set comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Code(node[1].attr, sel...
def setcomprehension_walk3(self, node, collection_index): """Set comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Code(node[1].attr, sel...
[ "Set", "comprehensions", "the", "way", "they", "are", "done", "in", "Python3", ".", "They", "re", "more", "other", "comprehensions", "e", ".", "g", ".", "set", "comprehensions", "See", "if", "we", "can", "combine", "code", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1294-L1339
[ "def", "setcomprehension_walk3", "(", "self", ",", "node", ",", "collection_index", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "Code", "(", "node", "[", "1", "]", ".", "attr", ",", "self", ".", "scanner", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.n_dict
prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42}" We will source-code use line breaks to guide us when to break.
uncompyle6/semantics/pysource.py
def n_dict(self, node): """ prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42}" We will source-code use line breaks to guide us when to break. """ p = self.prec self.prec = 100 self.indent_more(INDENT_PER_LEVEL) sep = INDENT_PER_LEV...
def n_dict(self, node): """ prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42}" We will source-code use line breaks to guide us when to break. """ p = self.prec self.prec = 100 self.indent_more(INDENT_PER_LEVEL) sep = INDENT_PER_LEV...
[ "prettyprint", "a", "dict", "dict", "is", "something", "like", "k", "=", "{", "a", ":", "1", "b", ":", "42", "}", "We", "will", "source", "-", "code", "use", "line", "breaks", "to", "guide", "us", "when", "to", "break", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1494-L1672
[ "def", "n_dict", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "100", "self", ".", "indent_more", "(", "INDENT_PER_LEVEL", ")", "sep", "=", "INDENT_PER_LEVEL", "[", ":", "-", "1", "]", "if", "node", "[...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.n_list
prettyprint a list or tuple
uncompyle6/semantics/pysource.py
def n_list(self, node): """ prettyprint a list or tuple """ p = self.prec self.prec = 100 lastnode = node.pop() lastnodetype = lastnode.kind # If this build list is inside a CALL_FUNCTION_VAR, # then the first * has already been printed. #...
def n_list(self, node): """ prettyprint a list or tuple """ p = self.prec self.prec = 100 lastnode = node.pop() lastnodetype = lastnode.kind # If this build list is inside a CALL_FUNCTION_VAR, # then the first * has already been printed. #...
[ "prettyprint", "a", "list", "or", "tuple" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1674-L1754
[ "def", "n_list", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "100", "lastnode", "=", "node", ".", "pop", "(", ")", "lastnodetype", "=", "lastnode", ".", "kind", "# If this build list is inside a CALL_FUNCTIO...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.template_engine
The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on.
uncompyle6/semantics/pysource.py
def template_engine(self, entry, startnode): """The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on. """ # print("-----") # print(startnode) # print(en...
def template_engine(self, entry, startnode): """The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on. """ # print("-----") # print(startnode) # print(en...
[ "The", "format", "template", "interpetation", "engine", ".", "See", "the", "comment", "at", "the", "beginning", "of", "this", "module", "for", "the", "how", "we", "interpret", "format", "specifications", "such", "as", "%c", "%C", "and", "so", "on", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1816-L1934
[ "def", "template_engine", "(", "self", ",", "entry", ",", "startnode", ")", ":", "# print(\"-----\")", "# print(startnode)", "# print(entry[0])", "# print('======')", "fmt", "=", "entry", "[", "0", "]", "arg", "=", "1", "i", "=", "0", "m", "=", "escape", "."...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.customize
Special handling for opcodes, such as those that take a variable number of arguments -- we add a new entry for each in TABLE_R.
uncompyle6/semantics/pysource.py
def customize(self, customize): """ Special handling for opcodes, such as those that take a variable number of arguments -- we add a new entry for each in TABLE_R. """ for k, v in list(customize.items()): if k in TABLE_R: continue op = k[ :...
def customize(self, customize): """ Special handling for opcodes, such as those that take a variable number of arguments -- we add a new entry for each in TABLE_R. """ for k, v in list(customize.items()): if k in TABLE_R: continue op = k[ :...
[ "Special", "handling", "for", "opcodes", "such", "as", "those", "that", "take", "a", "variable", "number", "of", "arguments", "--", "we", "add", "a", "new", "entry", "for", "each", "in", "TABLE_R", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L1949-L2024
[ "def", "customize", "(", "self", ",", "customize", ")", ":", "for", "k", ",", "v", "in", "list", "(", "customize", ".", "items", "(", ")", ")", ":", "if", "k", "in", "TABLE_R", ":", "continue", "op", "=", "k", "[", ":", "k", ".", "rfind", "(", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.get_tuple_parameter
If the name of the formal parameter starts with dot, it's a tuple parameter, like this: # def MyFunc(xx, (a,b,c), yy): # print a, b*2, c*42 In byte-code, the whole tuple is assigned to parameter '.1' and then the tuple gets unpacked to 'a', 'b' and 'c'. ...
uncompyle6/semantics/pysource.py
def get_tuple_parameter(self, ast, name): """ If the name of the formal parameter starts with dot, it's a tuple parameter, like this: # def MyFunc(xx, (a,b,c), yy): # print a, b*2, c*42 In byte-code, the whole tuple is assigned to parameter '.1' ...
def get_tuple_parameter(self, ast, name): """ If the name of the formal parameter starts with dot, it's a tuple parameter, like this: # def MyFunc(xx, (a,b,c), yy): # print a, b*2, c*42 In byte-code, the whole tuple is assigned to parameter '.1' ...
[ "If", "the", "name", "of", "the", "formal", "parameter", "starts", "with", "dot", "it", "s", "a", "tuple", "parameter", "like", "this", ":", "#", "def", "MyFunc", "(", "xx", "(", "a", "b", "c", ")", "yy", ")", ":", "#", "print", "a", "b", "*", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L2026-L2057
[ "def", "get_tuple_parameter", "(", "self", ",", "ast", ",", "name", ")", ":", "assert", "ast", "==", "'stmts'", "for", "i", "in", "range", "(", "len", "(", "ast", ")", ")", ":", "# search for an assign-statement", "assert", "ast", "[", "i", "]", "[", "...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.build_class
Dump class definition, doc string and class body.
uncompyle6/semantics/pysource.py
def build_class(self, code): """Dump class definition, doc string and class body.""" assert iscode(code) self.classes.append(self.currentclass) code = Code(code, self.scanner, self.currentclass) indent = self.indent # self.println(indent, '#flags:\t', int(code.co_flags)...
def build_class(self, code): """Dump class definition, doc string and class body.""" assert iscode(code) self.classes.append(self.currentclass) code = Code(code, self.scanner, self.currentclass) indent = self.indent # self.println(indent, '#flags:\t', int(code.co_flags)...
[ "Dump", "class", "definition", "doc", "string", "and", "class", "body", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L2059-L2156
[ "def", "build_class", "(", "self", ",", "code", ")", ":", "assert", "iscode", "(", "code", ")", "self", ".", "classes", ".", "append", "(", "self", ".", "currentclass", ")", "code", "=", "Code", "(", "code", ",", "self", ".", "scanner", ",", "self", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
SourceWalker.gen_source
convert SyntaxTree to Python source code
uncompyle6/semantics/pysource.py
def gen_source(self, ast, name, customize, is_lambda=False, returnNone=False): """convert SyntaxTree to Python source code""" rn = self.return_none self.return_none = returnNone old_name = self.name self.name = name # if code would be empty, append 'pass' if len(...
def gen_source(self, ast, name, customize, is_lambda=False, returnNone=False): """convert SyntaxTree to Python source code""" rn = self.return_none self.return_none = returnNone old_name = self.name self.name = name # if code would be empty, append 'pass' if len(...
[ "convert", "SyntaxTree", "to", "Python", "source", "code" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/pysource.py#L2158-L2176
[ "def", "gen_source", "(", "self", ",", "ast", ",", "name", ",", "customize", ",", "is_lambda", "=", "False", ",", "returnNone", "=", "False", ")", ":", "rn", "=", "self", ".", "return_none", "self", ".", "return_none", "=", "returnNone", "old_name", "=",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
disco
diassembles and deparses a given code block 'co'
uncompyle6/disas.py
def disco(version, co, out=None, is_pypy=False): """ diassembles and deparses a given code block 'co' """ assert iscode(co) # store final output stream for case of error real_out = out or sys.stdout print('# Python %s' % version, file=real_out) if co.co_filename: print('# Embed...
def disco(version, co, out=None, is_pypy=False): """ diassembles and deparses a given code block 'co' """ assert iscode(co) # store final output stream for case of error real_out = out or sys.stdout print('# Python %s' % version, file=real_out) if co.co_filename: print('# Embed...
[ "diassembles", "and", "deparses", "a", "given", "code", "block", "co" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/disas.py#L43-L60
[ "def", "disco", "(", "version", ",", "co", ",", "out", "=", "None", ",", "is_pypy", "=", "False", ")", ":", "assert", "iscode", "(", "co", ")", "# store final output stream for case of error", "real_out", "=", "out", "or", "sys", ".", "stdout", "print", "(...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
disassemble_file
disassemble Python byte-code file (.pyc) If given a Python source file (".py") file, we'll try to find the corresponding compiled object.
uncompyle6/disas.py
def disassemble_file(filename, outstream=None): """ disassemble Python byte-code file (.pyc) If given a Python source file (".py") file, we'll try to find the corresponding compiled object. """ filename = check_object_path(filename) (version, timestamp, magic_int, co, is_pypy, source_s...
def disassemble_file(filename, outstream=None): """ disassemble Python byte-code file (.pyc) If given a Python source file (".py") file, we'll try to find the corresponding compiled object. """ filename = check_object_path(filename) (version, timestamp, magic_int, co, is_pypy, source_s...
[ "disassemble", "Python", "byte", "-", "code", "file", "(", ".", "pyc", ")" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/disas.py#L93-L108
[ "def", "disassemble_file", "(", "filename", ",", "outstream", "=", "None", ")", ":", "filename", "=", "check_object_path", "(", "filename", ")", "(", "version", ",", "timestamp", ",", "magic_int", ",", "co", ",", "is_pypy", ",", "source_size", ")", "=", "l...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python2Parser.customize_grammar_rules
The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific instructions that are in the instruction/token stream. I...
uncompyle6/parsers/parse2.py
def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific...
def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific...
[ "The", "base", "grammar", "we", "start", "out", "for", "a", "Python", "version", "even", "with", "the", "subclassing", "is", "well", "is", "pretty", "base", ".", "And", "we", "want", "it", "that", "way", ":", "lean", "and", "mean", "so", "that", "parsi...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse2.py#L233-L534
[ "def", "customize_grammar_rules", "(", "self", ",", "tokens", ",", "customize", ")", ":", "if", "'PyPy'", "in", "customize", ":", "# PyPy-specific customizations", "self", ".", "addRule", "(", "\"\"\"\n stmt ::= assign3_pypy\n stm...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
code_deparse_align
ingests and deparses a given code block 'co'
uncompyle6/semantics/aligner.py
def code_deparse_align(co, out=sys.stderr, version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec'): """ ingests and deparses a given code block 'co' """ assert iscode(co) if version is None: version = fl...
def code_deparse_align(co, out=sys.stderr, version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec'): """ ingests and deparses a given code block 'co' """ assert iscode(co) if version is None: version = fl...
[ "ingests", "and", "deparses", "a", "given", "code", "block", "co" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/aligner.py#L110-L173
[ "def", "code_deparse_align", "(", "co", ",", "out", "=", "sys", ".", "stderr", ",", "version", "=", "None", ",", "is_pypy", "=", "None", ",", "debug_opts", "=", "DEFAULT_DEBUG_OPTS", ",", "code_objects", "=", "{", "}", ",", "compile_mode", "=", "'exec'", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
maybe_show_asm
Show the asm based on the showasm flag (or file object), writing to the appropriate stream depending on the type of the flag. :param showasm: Flag which determines whether the ingested code is written to sys.stdout or not. (It is also to pass a file like object, into whi...
uncompyle6/show.py
def maybe_show_asm(showasm, tokens): """ Show the asm based on the showasm flag (or file object), writing to the appropriate stream depending on the type of the flag. :param showasm: Flag which determines whether the ingested code is written to sys.stdout or not. (It is also to pass...
def maybe_show_asm(showasm, tokens): """ Show the asm based on the showasm flag (or file object), writing to the appropriate stream depending on the type of the flag. :param showasm: Flag which determines whether the ingested code is written to sys.stdout or not. (It is also to pass...
[ "Show", "the", "asm", "based", "on", "the", "showasm", "flag", "(", "or", "file", "object", ")", "writing", "to", "the", "appropriate", "stream", "depending", "on", "the", "type", "of", "the", "flag", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/show.py#L18-L32
[ "def", "maybe_show_asm", "(", "showasm", ",", "tokens", ")", ":", "if", "showasm", ":", "stream", "=", "showasm", "if", "hasattr", "(", "showasm", ",", "'write'", ")", "else", "sys", ".", "stdout", "for", "t", "in", "tokens", ":", "stream", ".", "write...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
maybe_show_tree
Show the ast based on the showast flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the parse tree is written to sys.stdout or not. (It is also to pass a file like object, into ...
uncompyle6/show.py
def maybe_show_tree(walker, ast): """ Show the ast based on the showast flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the parse tree is written to sys.stdout or not. (It is also to pass a...
def maybe_show_tree(walker, ast): """ Show the ast based on the showast flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the parse tree is written to sys.stdout or not. (It is also to pass a...
[ "Show", "the", "ast", "based", "on", "the", "showast", "flag", "(", "or", "file", "object", ")", "writing", "to", "the", "appropriate", "stream", "depending", "on", "the", "type", "of", "the", "flag", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/show.py#L35-L54
[ "def", "maybe_show_tree", "(", "walker", ",", "ast", ")", ":", "if", "walker", ".", "showast", ":", "if", "hasattr", "(", "walker", ".", "showast", ",", "'write'", ")", ":", "stream", "=", "walker", ".", "showast", "else", ":", "stream", "=", "sys", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
maybe_show_tree_param_default
Show a function parameter with default for an grammar-tree based on the show_tree flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the function parameter with default is written to sys.stdout or...
uncompyle6/show.py
def maybe_show_tree_param_default(show_tree, name, default): """ Show a function parameter with default for an grammar-tree based on the show_tree flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the function...
def maybe_show_tree_param_default(show_tree, name, default): """ Show a function parameter with default for an grammar-tree based on the show_tree flag (or file object), writing to the appropriate stream depending on the type of the flag. :param show_tree: Flag which determines whether the function...
[ "Show", "a", "function", "parameter", "with", "default", "for", "an", "grammar", "-", "tree", "based", "on", "the", "show_tree", "flag", "(", "or", "file", "object", ")", "writing", "to", "the", "appropriate", "stream", "depending", "on", "the", "type", "o...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/show.py#L57-L78
[ "def", "maybe_show_tree_param_default", "(", "show_tree", ",", "name", ",", "default", ")", ":", "if", "show_tree", ":", "stream", "=", "show_tree", "if", "hasattr", "(", "show_tree", ",", "'write'", ")", "else", "sys", ".", "stdout", "stream", ".", "write",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner15.ingest
Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar.
uncompyle6/scanners/scanner15.py
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. """ tokens, customize = sca...
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. """ tokens, customize = sca...
[ "Pick", "out", "tokens", "from", "an", "uncompyle6", "code", "object", "and", "transform", "them", "returning", "a", "list", "of", "uncompyle6", "Token", "s", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner15.py#L29-L41
[ "def", "ingest", "(", "self", ",", "co", ",", "classname", "=", "None", ",", "code_objects", "=", "{", "}", ",", "show_asm", "=", "None", ")", ":", "tokens", ",", "customize", "=", "scan", ".", "Scanner21", ".", "ingest", "(", "self", ",", "co", ",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.ingest
Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - various types of LOAD_CONST's are categorized in terms of what they load - COME_FROM...
uncompyle6/scanners/scanner3.py
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - variou...
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - variou...
[ "Pick", "out", "tokens", "from", "an", "uncompyle6", "code", "object", "and", "transform", "them", "returning", "a", "list", "of", "uncompyle6", "Token", "s", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L169-L451
[ "def", "ingest", "(", "self", ",", "co", ",", "classname", "=", "None", ",", "code_objects", "=", "{", "}", ",", "show_asm", "=", "None", ")", ":", "if", "not", "show_asm", ":", "show_asm", "=", "self", ".", "show_asm", "bytecode", "=", "self", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.find_jump_targets
Detect all offsets in a byte code which are jump targets where we might insert a COME_FROM instruction. Return the list of offsets. Return the list of offsets. An instruction can be jumped to in from multiple instructions.
uncompyle6/scanners/scanner3.py
def find_jump_targets(self, debug): """ Detect all offsets in a byte code which are jump targets where we might insert a COME_FROM instruction. Return the list of offsets. Return the list of offsets. An instruction can be jumped to in from multiple instructions. ...
def find_jump_targets(self, debug): """ Detect all offsets in a byte code which are jump targets where we might insert a COME_FROM instruction. Return the list of offsets. Return the list of offsets. An instruction can be jumped to in from multiple instructions. ...
[ "Detect", "all", "offsets", "in", "a", "byte", "code", "which", "are", "jump", "targets", "where", "we", "might", "insert", "a", "COME_FROM", "instruction", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L453-L526
[ "def", "find_jump_targets", "(", "self", ",", "debug", ")", ":", "code", "=", "self", ".", "code", "n", "=", "len", "(", "code", ")", "self", ".", "structs", "=", "[", "{", "'type'", ":", "'root'", ",", "'start'", ":", "0", ",", "'end'", ":", "n"...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.detect_control_flow
Detect type of block structures and their boundaries to fix optimized jumps in python2.3+
uncompyle6/scanners/scanner3.py
def detect_control_flow(self, offset, targets, inst_index): """ Detect type of block structures and their boundaries to fix optimized jumps in python2.3+ """ code = self.code inst = self.insts[inst_index] op = inst.opcode # Detect parent structure ...
def detect_control_flow(self, offset, targets, inst_index): """ Detect type of block structures and their boundaries to fix optimized jumps in python2.3+ """ code = self.code inst = self.insts[inst_index] op = inst.opcode # Detect parent structure ...
[ "Detect", "type", "of", "block", "structures", "and", "their", "boundaries", "to", "fix", "optimized", "jumps", "in", "python2", ".", "3", "+" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L611-L1025
[ "def", "detect_control_flow", "(", "self", ",", "offset", ",", "targets", ",", "inst_index", ")", ":", "code", "=", "self", ".", "code", "inst", "=", "self", ".", "insts", "[", "inst_index", "]", "op", "=", "inst", ".", "opcode", "# Detect parent structure...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.is_jump_back
Return True if the code at offset is some sort of jump back. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward.
uncompyle6/scanners/scanner3.py
def is_jump_back(self, offset, extended_arg): """ Return True if the code at offset is some sort of jump back. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward. """ if self.code[offset] != self.opc.JUMP_ABSOLUTE: return False r...
def is_jump_back(self, offset, extended_arg): """ Return True if the code at offset is some sort of jump back. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward. """ if self.code[offset] != self.opc.JUMP_ABSOLUTE: return False r...
[ "Return", "True", "if", "the", "code", "at", "offset", "is", "some", "sort", "of", "jump", "back", ".", "That", "is", "it", "is", "ether", "JUMP_FORWARD", "or", "an", "absolute", "jump", "that", "goes", "forward", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L1027-L1035
[ "def", "is_jump_back", "(", "self", ",", "offset", ",", "extended_arg", ")", ":", "if", "self", ".", "code", "[", "offset", "]", "!=", "self", ".", "opc", ".", "JUMP_ABSOLUTE", ":", "return", "False", "return", "offset", ">", "self", ".", "get_target", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.next_except_jump
Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found.
uncompyle6/scanners/scanner3.py
def next_except_jump(self, start): """ Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found. """ if self.code[start] == self.opc.DUP_TOP: except_match = self.first_instr(start, len(self.cod...
def next_except_jump(self, start): """ Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found. """ if self.code[start] == self.opc.DUP_TOP: except_match = self.first_instr(start, len(self.cod...
[ "Return", "the", "next", "jump", "that", "was", "generated", "by", "an", "except", "SomeException", ":", "construct", "in", "a", "try", "...", "except", "...", "else", "clause", "or", "None", "if", "not", "found", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L1037-L1064
[ "def", "next_except_jump", "(", "self", ",", "start", ")", ":", "if", "self", ".", "code", "[", "start", "]", "==", "self", ".", "opc", ".", "DUP_TOP", ":", "except_match", "=", "self", ".", "first_instr", "(", "start", ",", "len", "(", "self", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner3.rem_or
Find offsets of all requested <instr> between <start> and <end>, optionally <target>ing specified offset, and return list found <instr> offsets which are not within any POP_JUMP_IF_TRUE jumps.
uncompyle6/scanners/scanner3.py
def rem_or(self, start, end, instr, target=None, include_beyond_target=False): """ Find offsets of all requested <instr> between <start> and <end>, optionally <target>ing specified offset, and return list found <instr> offsets which are not within any POP_JUMP_IF_TRUE jumps. """ ...
def rem_or(self, start, end, instr, target=None, include_beyond_target=False): """ Find offsets of all requested <instr> between <start> and <end>, optionally <target>ing specified offset, and return list found <instr> offsets which are not within any POP_JUMP_IF_TRUE jumps. """ ...
[ "Find", "offsets", "of", "all", "requested", "<instr", ">", "between", "<start", ">", "and", "<end", ">", "optionally", "<target", ">", "ing", "specified", "offset", "and", "return", "list", "found", "<instr", ">", "offsets", "which", "are", "not", "within",...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner3.py#L1066-L1091
[ "def", "rem_or", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "include_beyond_target", "=", "False", ")", ":", "assert", "(", "start", ">=", "0", "and", "end", "<=", "len", "(", "self", ".", "code", ")", "an...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.build_instructions
Create a list of instructions (a structured object rather than an array of bytes) and store that in self.insts
uncompyle6/scanner.py
def build_instructions(self, co): """ Create a list of instructions (a structured object rather than an array of bytes) and store that in self.insts """ # FIXME: remove this when all subsidiary functions have been removed. # We should be able to get everything from the se...
def build_instructions(self, co): """ Create a list of instructions (a structured object rather than an array of bytes) and store that in self.insts """ # FIXME: remove this when all subsidiary functions have been removed. # We should be able to get everything from the se...
[ "Create", "a", "list", "of", "instructions", "(", "a", "structured", "object", "rather", "than", "an", "array", "of", "bytes", ")", "and", "store", "that", "in", "self", ".", "insts" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L96-L113
[ "def", "build_instructions", "(", "self", ",", "co", ")", ":", "# FIXME: remove this when all subsidiary functions have been removed.", "# We should be able to get everything from the self.insts list.", "self", ".", "code", "=", "array", "(", "'B'", ",", "co", ".", "co_code",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.build_lines_data
Generate various line-related helper data.
uncompyle6/scanner.py
def build_lines_data(self, code_obj): """ Generate various line-related helper data. """ # Offset: lineno pairs, only for offsets which start line. # Locally we use list for more convenient iteration using indices if self.version > 1.4: linestarts = list(self...
def build_lines_data(self, code_obj): """ Generate various line-related helper data. """ # Offset: lineno pairs, only for offsets which start line. # Locally we use list for more convenient iteration using indices if self.version > 1.4: linestarts = list(self...
[ "Generate", "various", "line", "-", "related", "helper", "data", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L115-L150
[ "def", "build_lines_data", "(", "self", ",", "code_obj", ")", ":", "# Offset: lineno pairs, only for offsets which start line.", "# Locally we use list for more convenient iteration using indices", "if", "self", ".", "version", ">", "1.4", ":", "linestarts", "=", "list", "(",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.build_prev_op
Compose 'list-map' which allows to jump to previous op, given offset of current op as index.
uncompyle6/scanner.py
def build_prev_op(self): """ Compose 'list-map' which allows to jump to previous op, given offset of current op as index. """ code = self.code codelen = len(code) # 2.x uses prev 3.x uses prev_op. Sigh # Until we get this sorted out. self.prev = se...
def build_prev_op(self): """ Compose 'list-map' which allows to jump to previous op, given offset of current op as index. """ code = self.code codelen = len(code) # 2.x uses prev 3.x uses prev_op. Sigh # Until we get this sorted out. self.prev = se...
[ "Compose", "list", "-", "map", "which", "allows", "to", "jump", "to", "previous", "op", "given", "offset", "of", "current", "op", "as", "index", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L152-L165
[ "def", "build_prev_op", "(", "self", ")", ":", "code", "=", "self", ".", "code", "codelen", "=", "len", "(", "code", ")", "# 2.x uses prev 3.x uses prev_op. Sigh", "# Until we get this sorted out.", "self", ".", "prev", "=", "self", ".", "prev_op", "=", "[", "...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.is_jump_forward
Return True if the code at offset is some sort of jump forward. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward.
uncompyle6/scanner.py
def is_jump_forward(self, offset): """ Return True if the code at offset is some sort of jump forward. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward. """ opname = self.get_inst(offset).opname if opname == 'JUMP_FORWARD': ret...
def is_jump_forward(self, offset): """ Return True if the code at offset is some sort of jump forward. That is, it is ether "JUMP_FORWARD" or an absolute jump that goes forward. """ opname = self.get_inst(offset).opname if opname == 'JUMP_FORWARD': ret...
[ "Return", "True", "if", "the", "code", "at", "offset", "is", "some", "sort", "of", "jump", "forward", ".", "That", "is", "it", "is", "ether", "JUMP_FORWARD", "or", "an", "absolute", "jump", "that", "goes", "forward", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L167-L178
[ "def", "is_jump_forward", "(", "self", ",", "offset", ")", ":", "opname", "=", "self", ".", "get_inst", "(", "offset", ")", ".", "opname", "if", "opname", "==", "'JUMP_FORWARD'", ":", "return", "True", "if", "opname", "!=", "'JUMP_ABSOLUTE'", ":", "return"...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.get_target
Get next instruction offset for op located at given <offset>. NOTE: extended_arg is no longer used
uncompyle6/scanner.py
def get_target(self, offset, extended_arg=0): """ Get next instruction offset for op located at given <offset>. NOTE: extended_arg is no longer used """ inst = self.get_inst(offset) if inst.opcode in self.opc.JREL_OPS | self.opc.JABS_OPS: target = inst.argval ...
def get_target(self, offset, extended_arg=0): """ Get next instruction offset for op located at given <offset>. NOTE: extended_arg is no longer used """ inst = self.get_inst(offset) if inst.opcode in self.opc.JREL_OPS | self.opc.JABS_OPS: target = inst.argval ...
[ "Get", "next", "instruction", "offset", "for", "op", "located", "at", "given", "<offset", ">", ".", "NOTE", ":", "extended_arg", "is", "no", "longer", "used" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L194-L205
[ "def", "get_target", "(", "self", ",", "offset", ",", "extended_arg", "=", "0", ")", ":", "inst", "=", "self", ".", "get_inst", "(", "offset", ")", "if", "inst", ".", "opcode", "in", "self", ".", "opc", ".", "JREL_OPS", "|", "self", ".", "opc", "."...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.first_instr
Find the first <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified which must match precisely if exact is True, or if exact is False, the instruc...
uncompyle6/scanner.py
def first_instr(self, start, end, instr, target=None, exact=True): """ Find the first <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified...
def first_instr(self, start, end, instr, target=None, exact=True): """ Find the first <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified...
[ "Find", "the", "first", "<instr", ">", "in", "the", "block", "from", "start", "to", "end", ".", "<instr", ">", "is", "any", "python", "bytecode", "instruction", "or", "a", "list", "of", "opcodes", "If", "<instr", ">", "is", "an", "opcode", "with", "a",...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L223-L257
[ "def", "first_instr", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "exact", "=", "True", ")", ":", "code", "=", "self", ".", "code", "assert", "(", "start", ">=", "0", "and", "end", "<=", "len", "(", "code...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.last_instr
Find the last <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified which must match precisely if exact is True, or if exact is False, the instruct...
uncompyle6/scanner.py
def last_instr(self, start, end, instr, target=None, exact=True): """ Find the last <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified w...
def last_instr(self, start, end, instr, target=None, exact=True): """ Find the last <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified w...
[ "Find", "the", "last", "<instr", ">", "in", "the", "block", "from", "start", "to", "end", ".", "<instr", ">", "is", "any", "python", "bytecode", "instruction", "or", "a", "list", "of", "opcodes", "If", "<instr", ">", "is", "an", "opcode", "with", "a", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L259-L313
[ "def", "last_instr", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "exact", "=", "True", ")", ":", "code", "=", "self", ".", "code", "# Make sure requested positions do not go out of", "# code bounds", "if", "not", "("...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.inst_matches
Find all `instr` in the block from start to end. `instr` is a Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified which must match precisely. Return a list with indexes to them or [] if none found.
uncompyle6/scanner.py
def inst_matches(self, start, end, instr, target=None, include_beyond_target=False): """ Find all `instr` in the block from start to end. `instr` is a Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified whi...
def inst_matches(self, start, end, instr, target=None, include_beyond_target=False): """ Find all `instr` in the block from start to end. `instr` is a Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified whi...
[ "Find", "all", "instr", "in", "the", "block", "from", "start", "to", "end", ".", "instr", "is", "a", "Python", "opcode", "or", "a", "list", "of", "opcodes", "If", "instr", "is", "an", "opcode", "with", "a", "target", "(", "like", "a", "jump", ")", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L315-L352
[ "def", "inst_matches", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "include_beyond_target", "=", "False", ")", ":", "try", ":", "None", "in", "instr", "except", ":", "instr", "=", "[", "instr", "]", "first", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.all_instr
Find all `instr` in the block from start to end. `instr` is any Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified which must match precisely. Return a list with indexes to them or [] if none found.
uncompyle6/scanner.py
def all_instr(self, start, end, instr, target=None, include_beyond_target=False): """ Find all `instr` in the block from start to end. `instr` is any Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified whic...
def all_instr(self, start, end, instr, target=None, include_beyond_target=False): """ Find all `instr` in the block from start to end. `instr` is any Python opcode or a list of opcodes If `instr` is an opcode with a target (like a jump), a target destination can be specified whic...
[ "Find", "all", "instr", "in", "the", "block", "from", "start", "to", "end", ".", "instr", "is", "any", "Python", "opcode", "or", "a", "list", "of", "opcodes", "If", "instr", "is", "an", "opcode", "with", "a", "target", "(", "like", "a", "jump", ")", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L357-L401
[ "def", "all_instr", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "include_beyond_target", "=", "False", ")", ":", "code", "=", "self", ".", "code", "assert", "(", "start", ">=", "0", "and", "end", "<=", "len",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.op_range
Iterate through positions of opcodes, skipping arguments.
uncompyle6/scanner.py
def op_range(self, start, end): """ Iterate through positions of opcodes, skipping arguments. """ while start < end: yield start start += instruction_size(self.code[start], self.opc)
def op_range(self, start, end): """ Iterate through positions of opcodes, skipping arguments. """ while start < end: yield start start += instruction_size(self.code[start], self.opc)
[ "Iterate", "through", "positions", "of", "opcodes", "skipping", "arguments", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L409-L416
[ "def", "op_range", "(", "self", ",", "start", ",", "end", ")", ":", "while", "start", "<", "end", ":", "yield", "start", "start", "+=", "instruction_size", "(", "self", ".", "code", "[", "start", "]", ",", "self", ".", "opc", ")" ]
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.remove_extended_args
Go through instructions removing extended ARG. get_instruction_bytes previously adjusted the operand values to account for these
uncompyle6/scanner.py
def remove_extended_args(self, instructions): """Go through instructions removing extended ARG. get_instruction_bytes previously adjusted the operand values to account for these""" new_instructions = [] last_was_extarg = False n = len(instructions) for i, inst in ...
def remove_extended_args(self, instructions): """Go through instructions removing extended ARG. get_instruction_bytes previously adjusted the operand values to account for these""" new_instructions = [] last_was_extarg = False n = len(instructions) for i, inst in ...
[ "Go", "through", "instructions", "removing", "extended", "ARG", ".", "get_instruction_bytes", "previously", "adjusted", "the", "operand", "values", "to", "account", "for", "these" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L418-L452
[ "def", "remove_extended_args", "(", "self", ",", "instructions", ")", ":", "new_instructions", "=", "[", "]", "last_was_extarg", "=", "False", "n", "=", "len", "(", "instructions", ")", "for", "i", ",", "inst", "in", "enumerate", "(", "instructions", ")", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.remove_mid_line_ifs
Go through passed offsets, filtering ifs located somewhere mid-line.
uncompyle6/scanner.py
def remove_mid_line_ifs(self, ifs): """ Go through passed offsets, filtering ifs located somewhere mid-line. """ # FIXME: this doesn't work for Python 3.6+ filtered = [] for i in ifs: # For each offset, if line number of current and next op ...
def remove_mid_line_ifs(self, ifs): """ Go through passed offsets, filtering ifs located somewhere mid-line. """ # FIXME: this doesn't work for Python 3.6+ filtered = [] for i in ifs: # For each offset, if line number of current and next op ...
[ "Go", "through", "passed", "offsets", "filtering", "ifs", "located", "somewhere", "mid", "-", "line", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L454-L471
[ "def", "remove_mid_line_ifs", "(", "self", ",", "ifs", ")", ":", "# FIXME: this doesn't work for Python 3.6+", "filtered", "=", "[", "]", "for", "i", "in", "ifs", ":", "# For each offset, if line number of current and next op", "# is the same", "if", "self", ".", "lines...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner.restrict_to_parent
Restrict target to parent structure boundaries.
uncompyle6/scanner.py
def restrict_to_parent(self, target, parent): """Restrict target to parent structure boundaries.""" if not (parent['start'] < target < parent['end']): target = parent['end'] return target
def restrict_to_parent(self, target, parent): """Restrict target to parent structure boundaries.""" if not (parent['start'] < target < parent['end']): target = parent['end'] return target
[ "Restrict", "target", "to", "parent", "structure", "boundaries", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanner.py#L476-L480
[ "def", "restrict_to_parent", "(", "self", ",", "target", ",", "parent", ")", ":", "if", "not", "(", "parent", "[", "'start'", "]", "<", "target", "<", "parent", "[", "'end'", "]", ")", ":", "target", "=", "parent", "[", "'end'", "]", "return", "targe...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
get_python_parser
Returns parser object for Python version 2 or 3, 3.2, 3.5on, etc., depending on the parameters passed. *compile_mode* is either 'exec', 'eval', or 'single'. See https://docs.python.org/3.6/library/functions.html#compile for an explanation of the different modes.
uncompyle6/parser.py
def get_python_parser( version, debug_parser=PARSER_DEFAULT_DEBUG, compile_mode='exec', is_pypy = False): """Returns parser object for Python version 2 or 3, 3.2, 3.5on, etc., depending on the parameters passed. *compile_mode* is either 'exec', 'eval', or 'single'. See https://docs.pyth...
def get_python_parser( version, debug_parser=PARSER_DEFAULT_DEBUG, compile_mode='exec', is_pypy = False): """Returns parser object for Python version 2 or 3, 3.2, 3.5on, etc., depending on the parameters passed. *compile_mode* is either 'exec', 'eval', or 'single'. See https://docs.pyth...
[ "Returns", "parser", "object", "for", "Python", "version", "2", "or", "3", "3", ".", "2", "3", ".", "5on", "etc", ".", "depending", "on", "the", "parameters", "passed", ".", "*", "compile_mode", "*", "is", "either", "exec", "eval", "or", "single", ".",...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L610-L763
[ "def", "get_python_parser", "(", "version", ",", "debug_parser", "=", "PARSER_DEFAULT_DEBUG", ",", "compile_mode", "=", "'exec'", ",", "is_pypy", "=", "False", ")", ":", "# If version is a string, turn that into the corresponding float.", "if", "isinstance", "(", "version...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
python_parser
Parse a code object to an abstract syntax tree representation. :param version: The python version this code is from as a float, for example 2.6, 2.7, 3.2, 3.3, 3.4, 3.5 etc. :param co: The code object to parse. :param out: File like object to wri...
uncompyle6/parser.py
def python_parser(version, co, out=sys.stdout, showasm=False, parser_debug=PARSER_DEFAULT_DEBUG, is_pypy=False): """ Parse a code object to an abstract syntax tree representation. :param version: The python version this code is from as a float, for exam...
def python_parser(version, co, out=sys.stdout, showasm=False, parser_debug=PARSER_DEFAULT_DEBUG, is_pypy=False): """ Parse a code object to an abstract syntax tree representation. :param version: The python version this code is from as a float, for exam...
[ "Parse", "a", "code", "object", "to", "an", "abstract", "syntax", "tree", "representation", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L775-L801
[ "def", "python_parser", "(", "version", ",", "co", ",", "out", "=", "sys", ".", "stdout", ",", "showasm", "=", "False", ",", "parser_debug", "=", "PARSER_DEFAULT_DEBUG", ",", "is_pypy", "=", "False", ")", ":", "assert", "iscode", "(", "co", ")", "from", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.add_unique_rule
Add rule to grammar, but only if it hasn't been added previously opname and stack_count are used in the customize() semantic the actions to add the semantic action rule. Stack_count is used in custom opcodes like MAKE_FUNCTION to indicate how many arguments it has. Often it i...
uncompyle6/parser.py
def add_unique_rule(self, rule, opname, arg_count, customize): """Add rule to grammar, but only if it hasn't been added previously opname and stack_count are used in the customize() semantic the actions to add the semantic action rule. Stack_count is used in custom opcodes like ...
def add_unique_rule(self, rule, opname, arg_count, customize): """Add rule to grammar, but only if it hasn't been added previously opname and stack_count are used in the customize() semantic the actions to add the semantic action rule. Stack_count is used in custom opcodes like ...
[ "Add", "rule", "to", "grammar", "but", "only", "if", "it", "hasn", "t", "been", "added", "previously", "opname", "and", "stack_count", "are", "used", "in", "the", "customize", "()", "semantic", "the", "actions", "to", "add", "the", "semantic", "action", "r...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L97-L110
[ "def", "add_unique_rule", "(", "self", ",", "rule", ",", "opname", ",", "arg_count", ",", "customize", ")", ":", "if", "rule", "not", "in", "self", ".", "new_rules", ":", "# print(\"XXX \", rule) # debug", "self", ".", "new_rules", ".", "add", "(", "rule", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.add_unique_rules
Add rules (a list of string) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary.
uncompyle6/parser.py
def add_unique_rules(self, rules, customize): """Add rules (a list of string) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary. """ for rule in rules: if len(rule) == 0: continue opname = rule.sp...
def add_unique_rules(self, rules, customize): """Add rules (a list of string) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary. """ for rule in rules: if len(rule) == 0: continue opname = rule.sp...
[ "Add", "rules", "(", "a", "list", "of", "string", ")", "to", "grammar", ".", "Note", "that", "the", "rules", "must", "not", "be", "those", "that", "set", "arg_count", "in", "the", "custom", "dictionary", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L112-L122
[ "def", "add_unique_rules", "(", "self", ",", "rules", ",", "customize", ")", ":", "for", "rule", "in", "rules", ":", "if", "len", "(", "rule", ")", "==", "0", ":", "continue", "opname", "=", "rule", ".", "split", "(", "'::='", ")", "[", "0", "]", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.add_unique_doc_rules
Add rules (a docstring-like list of rules) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary.
uncompyle6/parser.py
def add_unique_doc_rules(self, rules_str, customize): """Add rules (a docstring-like list of rules) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary. """ rules = [r.strip() for r in rules_str.split("\n")] self.add_unique_rules(...
def add_unique_doc_rules(self, rules_str, customize): """Add rules (a docstring-like list of rules) to grammar. Note that the rules must not be those that set arg_count in the custom dictionary. """ rules = [r.strip() for r in rules_str.split("\n")] self.add_unique_rules(...
[ "Add", "rules", "(", "a", "docstring", "-", "like", "list", "of", "rules", ")", "to", "grammar", ".", "Note", "that", "the", "rules", "must", "not", "be", "those", "that", "set", "arg_count", "in", "the", "custom", "dictionary", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L124-L131
[ "def", "add_unique_doc_rules", "(", "self", ",", "rules_str", ",", "customize", ")", ":", "rules", "=", "[", "r", ".", "strip", "(", ")", "for", "r", "in", "rules_str", ".", "split", "(", "\"\\n\"", ")", "]", "self", ".", "add_unique_rules", "(", "rule...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.cleanup
Remove recursive references to allow garbage collector to collect this object.
uncompyle6/parser.py
def cleanup(self): """ Remove recursive references to allow garbage collector to collect this object. """ for dict in (self.rule2func, self.rules, self.rule2name): for i in list(dict.keys()): dict[i] = None for i in dir(self): setat...
def cleanup(self): """ Remove recursive references to allow garbage collector to collect this object. """ for dict in (self.rule2func, self.rules, self.rule2name): for i in list(dict.keys()): dict[i] = None for i in dir(self): setat...
[ "Remove", "recursive", "references", "to", "allow", "garbage", "collector", "to", "collect", "this", "object", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L133-L142
[ "def", "cleanup", "(", "self", ")", ":", "for", "dict", "in", "(", "self", ".", "rule2func", ",", "self", ".", "rules", ",", "self", ".", "rule2name", ")", ":", "for", "i", "in", "list", "(", "dict", ".", "keys", "(", ")", ")", ":", "dict", "["...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.debug_reduce
Customized format and print for our kind of tokens which gets called in debugging grammar reduce rules
uncompyle6/parser.py
def debug_reduce(self, rule, tokens, parent, last_token_pos): """Customized format and print for our kind of tokens which gets called in debugging grammar reduce rules """ def fix(c): s = str(c) last_token_pos = s.find('_') if last_token_pos == -1: ...
def debug_reduce(self, rule, tokens, parent, last_token_pos): """Customized format and print for our kind of tokens which gets called in debugging grammar reduce rules """ def fix(c): s = str(c) last_token_pos = s.find('_') if last_token_pos == -1: ...
[ "Customized", "format", "and", "print", "for", "our", "kind", "of", "tokens", "which", "gets", "called", "in", "debugging", "grammar", "reduce", "rules" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L144-L172
[ "def", "debug_reduce", "(", "self", ",", "rule", ",", "tokens", ",", "parent", ",", "last_token_pos", ")", ":", "def", "fix", "(", "c", ")", ":", "s", "=", "str", "(", "c", ")", "last_token_pos", "=", "s", ".", "find", "(", "'_'", ")", "if", "las...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
PythonParser.get_pos_kw
Return then the number of positional parameters and represented by the attr field of token
uncompyle6/parser.py
def get_pos_kw(self, token): """Return then the number of positional parameters and represented by the attr field of token""" # Low byte indicates number of positional paramters, # high byte number of keyword parameters args_pos = token.attr & 0xff args_kw = (token.attr >...
def get_pos_kw(self, token): """Return then the number of positional parameters and represented by the attr field of token""" # Low byte indicates number of positional paramters, # high byte number of keyword parameters args_pos = token.attr & 0xff args_kw = (token.attr >...
[ "Return", "then", "the", "number", "of", "positional", "parameters", "and", "represented", "by", "the", "attr", "field", "of", "token" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parser.py#L196-L203
[ "def", "get_pos_kw", "(", "self", ",", "token", ")", ":", "# Low byte indicates number of positional paramters,", "# high byte number of keyword parameters", "args_pos", "=", "token", ".", "attr", "&", "0xff", "args_kw", "=", "(", "token", ".", "attr", ">>", "8", ")...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.unmangle_name
Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name.
uncompyle6/scanners/scanner2.py
def unmangle_name(name, classname): """Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name. """ if name.startswith(classname) and name[-2:] != '__': return name[len(classname) - 2:] return name
def unmangle_name(name, classname): """Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name. """ if name.startswith(classname) and name[-2:] != '__': return name[len(classname) - 2:] return name
[ "Remove", "__", "from", "the", "end", "of", "_name_", "if", "it", "starts", "with", "__classname__", "return", "the", "unmangled", "name", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L125-L131
[ "def", "unmangle_name", "(", "name", ",", "classname", ")", ":", "if", "name", ".", "startswith", "(", "classname", ")", "and", "name", "[", "-", "2", ":", "]", "!=", "'__'", ":", "return", "name", "[", "len", "(", "classname", ")", "-", "2", ":", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.unmangle_code_names
Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name.
uncompyle6/scanners/scanner2.py
def unmangle_code_names(self, co, classname): """Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name. """ if classname: classname = '_' + classname.lstrip('_') + '__' free = [ self.unmangle_name(name, classname) ...
def unmangle_code_names(self, co, classname): """Remove __ from the end of _name_ if it starts with __classname__ return the "unmangled" name. """ if classname: classname = '_' + classname.lstrip('_') + '__' free = [ self.unmangle_name(name, classname) ...
[ "Remove", "__", "from", "the", "end", "of", "_name_", "if", "it", "starts", "with", "__classname__", "return", "the", "unmangled", "name", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L134-L151
[ "def", "unmangle_code_names", "(", "self", ",", "co", ",", "classname", ")", ":", "if", "classname", ":", "classname", "=", "'_'", "+", "classname", ".", "lstrip", "(", "'_'", ")", "+", "'__'", "free", "=", "[", "self", ".", "unmangle_name", "(", "name...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.ingest
Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - various types of LOAD_CONST's are categorized in terms of what they load - COME_FROM...
uncompyle6/scanners/scanner2.py
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - variou...
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 Token's. The transformations are made to assist the deparsing grammar. Specificially: - variou...
[ "Pick", "out", "tokens", "from", "an", "uncompyle6", "code", "object", "and", "transform", "them", "returning", "a", "list", "of", "uncompyle6", "Token", "s", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L153-L399
[ "def", "ingest", "(", "self", ",", "co", ",", "classname", "=", "None", ",", "code_objects", "=", "{", "}", ",", "show_asm", "=", "None", ")", ":", "if", "not", "show_asm", ":", "show_asm", "=", "self", ".", "show_asm", "bytecode", "=", "self", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.next_except_jump
Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found.
uncompyle6/scanners/scanner2.py
def next_except_jump(self, start): """ Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found. """ if self.code[start] == self.opc.DUP_TOP: except_match = self.first_instr(start, len(self.cod...
def next_except_jump(self, start): """ Return the next jump that was generated by an except SomeException: construct in a try...except...else clause or None if not found. """ if self.code[start] == self.opc.DUP_TOP: except_match = self.first_instr(start, len(self.cod...
[ "Return", "the", "next", "jump", "that", "was", "generated", "by", "an", "except", "SomeException", ":", "construct", "in", "a", "try", "...", "except", "...", "else", "clause", "or", "None", "if", "not", "found", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L477-L518
[ "def", "next_except_jump", "(", "self", ",", "start", ")", ":", "if", "self", ".", "code", "[", "start", "]", "==", "self", ".", "opc", ".", "DUP_TOP", ":", "except_match", "=", "self", ".", "first_instr", "(", "start", ",", "len", "(", "self", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.detect_control_flow
Detect type of block structures and their boundaries to fix optimized jumps in python2.3+
uncompyle6/scanners/scanner2.py
def detect_control_flow(self, offset, op, extended_arg): """ Detect type of block structures and their boundaries to fix optimized jumps in python2.3+ """ code = self.code # Detect parent structure parent = self.structs[0] start = parent['start'] ...
def detect_control_flow(self, offset, op, extended_arg): """ Detect type of block structures and their boundaries to fix optimized jumps in python2.3+ """ code = self.code # Detect parent structure parent = self.structs[0] start = parent['start'] ...
[ "Detect", "type", "of", "block", "structures", "and", "their", "boundaries", "to", "fix", "optimized", "jumps", "in", "python2", ".", "3", "+" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L520-L1031
[ "def", "detect_control_flow", "(", "self", ",", "offset", ",", "op", ",", "extended_arg", ")", ":", "code", "=", "self", ".", "code", "# Detect parent structure", "parent", "=", "self", ".", "structs", "[", "0", "]", "start", "=", "parent", "[", "'start'",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.find_jump_targets
Detect all offsets in a byte code which are jump targets where we might insert a pseudo "COME_FROM" instruction. "COME_FROM" instructions are used in detecting overall control flow. The more detailed information about the control flow is captured in self.structs. Since this stuff...
uncompyle6/scanners/scanner2.py
def find_jump_targets(self, debug): """ Detect all offsets in a byte code which are jump targets where we might insert a pseudo "COME_FROM" instruction. "COME_FROM" instructions are used in detecting overall control flow. The more detailed information about the control fl...
def find_jump_targets(self, debug): """ Detect all offsets in a byte code which are jump targets where we might insert a pseudo "COME_FROM" instruction. "COME_FROM" instructions are used in detecting overall control flow. The more detailed information about the control fl...
[ "Detect", "all", "offsets", "in", "a", "byte", "code", "which", "are", "jump", "targets", "where", "we", "might", "insert", "a", "pseudo", "COME_FROM", "instruction", ".", "COME_FROM", "instructions", "are", "used", "in", "detecting", "overall", "control", "fl...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L1033-L1156
[ "def", "find_jump_targets", "(", "self", ",", "debug", ")", ":", "code", "=", "self", ".", "code", "n", "=", "len", "(", "code", ")", "self", ".", "structs", "=", "[", "{", "'type'", ":", "'root'", ",", "'start'", ":", "0", ",", "'end'", ":", "n"...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner2.rem_or
Find all <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be specified which must match precisely. Return a list with indexes to them or [] if none found.
uncompyle6/scanners/scanner2.py
def rem_or(self, start, end, instr, target=None, include_beyond_target=False): """ Find all <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be spe...
def rem_or(self, start, end, instr, target=None, include_beyond_target=False): """ Find all <instr> in the block from start to end. <instr> is any python bytecode instruction or a list of opcodes If <instr> is an opcode with a target (like a jump), a target destination can be spe...
[ "Find", "all", "<instr", ">", "in", "the", "block", "from", "start", "to", "end", ".", "<instr", ">", "is", "any", "python", "bytecode", "instruction", "or", "a", "list", "of", "opcodes", "If", "<instr", ">", "is", "an", "opcode", "with", "a", "target"...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner2.py#L1172-L1209
[ "def", "rem_or", "(", "self", ",", "start", ",", "end", ",", "instr", ",", "target", "=", "None", ",", "include_beyond_target", "=", "False", ")", ":", "assert", "(", "start", ">=", "0", "and", "end", "<=", "len", "(", "self", ".", "code", ")", "an...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python3Parser.call_fn_name
Customize CALL_FUNCTION to add the number of positional arguments
uncompyle6/parsers/parse3.py
def call_fn_name(token): """Customize CALL_FUNCTION to add the number of positional arguments""" if token.attr is not None: return '%s_%i' % (token.kind, token.attr) else: return '%s_0' % (token.kind)
def call_fn_name(token): """Customize CALL_FUNCTION to add the number of positional arguments""" if token.attr is not None: return '%s_%i' % (token.kind, token.attr) else: return '%s_0' % (token.kind)
[ "Customize", "CALL_FUNCTION", "to", "add", "the", "number", "of", "positional", "arguments" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L417-L422
[ "def", "call_fn_name", "(", "token", ")", ":", "if", "token", ".", "attr", "is", "not", "None", ":", "return", "'%s_%i'", "%", "(", "token", ".", "kind", ",", "token", ".", "attr", ")", "else", ":", "return", "'%s_0'", "%", "(", "token", ".", "kind...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python3Parser.custom_build_class_rule
# Should the first rule be somehow folded into the 2nd one? build_class ::= LOAD_BUILD_CLASS mkfunc LOAD_CLASSNAME {expr}^n-1 CALL_FUNCTION_n LOAD_CONST CALL_FUNCTION_n build_class ::= LOAD_BUILD_CLASS mkfunc expr ...
uncompyle6/parsers/parse3.py
def custom_build_class_rule(self, opname, i, token, tokens, customize): ''' # Should the first rule be somehow folded into the 2nd one? build_class ::= LOAD_BUILD_CLASS mkfunc LOAD_CLASSNAME {expr}^n-1 CALL_FUNCTION_n LOAD_CONST CALL_FUNCTION_n ...
def custom_build_class_rule(self, opname, i, token, tokens, customize): ''' # Should the first rule be somehow folded into the 2nd one? build_class ::= LOAD_BUILD_CLASS mkfunc LOAD_CLASSNAME {expr}^n-1 CALL_FUNCTION_n LOAD_CONST CALL_FUNCTION_n ...
[ "#", "Should", "the", "first", "rule", "be", "somehow", "folded", "into", "the", "2nd", "one?", "build_class", "::", "=", "LOAD_BUILD_CLASS", "mkfunc", "LOAD_CLASSNAME", "{", "expr", "}", "^n", "-", "1", "CALL_FUNCTION_n", "LOAD_CONST", "CALL_FUNCTION_n", "build...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L424-L478
[ "def", "custom_build_class_rule", "(", "self", ",", "opname", ",", "i", ",", "token", ",", "tokens", ",", "customize", ")", ":", "# FIXME: I bet this can be simplified", "# look for next MAKE_FUNCTION", "for", "i", "in", "range", "(", "i", "+", "1", ",", "len", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python3Parser.custom_classfunc_rule
call ::= expr {expr}^n CALL_FUNCTION_n call ::= expr {expr}^n CALL_FUNCTION_VAR_n call ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n call ::= expr {expr}^n CALL_FUNCTION_KW_n classdefdeco2 ::= LOAD_BUILD_CLASS mkfunc {expr}^n-1 CALL_FUNCTION_n
uncompyle6/parsers/parse3.py
def custom_classfunc_rule(self, opname, token, customize, next_token): """ call ::= expr {expr}^n CALL_FUNCTION_n call ::= expr {expr}^n CALL_FUNCTION_VAR_n call ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n call ::= expr {expr}^n CALL_FUNCTION_KW_n classdefdeco2 ::= LOAD_BUI...
def custom_classfunc_rule(self, opname, token, customize, next_token): """ call ::= expr {expr}^n CALL_FUNCTION_n call ::= expr {expr}^n CALL_FUNCTION_VAR_n call ::= expr {expr}^n CALL_FUNCTION_VAR_KW_n call ::= expr {expr}^n CALL_FUNCTION_KW_n classdefdeco2 ::= LOAD_BUI...
[ "call", "::", "=", "expr", "{", "expr", "}", "^n", "CALL_FUNCTION_n", "call", "::", "=", "expr", "{", "expr", "}", "^n", "CALL_FUNCTION_VAR_n", "call", "::", "=", "expr", "{", "expr", "}", "^n", "CALL_FUNCTION_VAR_KW_n", "call", "::", "=", "expr", "{", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L480-L515
[ "def", "custom_classfunc_rule", "(", "self", ",", "opname", ",", "token", ",", "customize", ",", "next_token", ")", ":", "args_pos", ",", "args_kw", "=", "self", ".", "get_pos_kw", "(", "token", ")", "# Additional exprs for * and ** args:", "# 0 if neither", "# ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python3Parser.add_make_function_rule
Python 3.3 added a an addtional LOAD_CONST before MAKE_FUNCTION and this has an effect on many rules.
uncompyle6/parsers/parse3.py
def add_make_function_rule(self, rule, opname, attr, customize): """Python 3.3 added a an addtional LOAD_CONST before MAKE_FUNCTION and this has an effect on many rules. """ if self.version >= 3.3: new_rule = rule % (('LOAD_CONST ') * 1) else: new_rule = r...
def add_make_function_rule(self, rule, opname, attr, customize): """Python 3.3 added a an addtional LOAD_CONST before MAKE_FUNCTION and this has an effect on many rules. """ if self.version >= 3.3: new_rule = rule % (('LOAD_CONST ') * 1) else: new_rule = r...
[ "Python", "3", ".", "3", "added", "a", "an", "addtional", "LOAD_CONST", "before", "MAKE_FUNCTION", "and", "this", "has", "an", "effect", "on", "many", "rules", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L517-L525
[ "def", "add_make_function_rule", "(", "self", ",", "rule", ",", "opname", ",", "attr", ",", "customize", ")", ":", "if", "self", ".", "version", ">=", "3.3", ":", "new_rule", "=", "rule", "%", "(", "(", "'LOAD_CONST '", ")", "*", "1", ")", "else", ":...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Python3Parser.customize_grammar_rules
The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific instructions that are in the instruction/token stream. I...
uncompyle6/parsers/parse3.py
def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific...
def customize_grammar_rules(self, tokens, customize): """The base grammar we start out for a Python version even with the subclassing is, well, is pretty base. And we want it that way: lean and mean so that parsing will go faster. Here, we add additional grammar rules based on specific...
[ "The", "base", "grammar", "we", "start", "out", "for", "a", "Python", "version", "even", "with", "the", "subclassing", "is", "well", "is", "pretty", "base", ".", "And", "we", "want", "it", "that", "way", ":", "lean", "and", "mean", "so", "that", "parsi...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/parsers/parse3.py#L527-L1164
[ "def", "customize_grammar_rules", "(", "self", ",", "tokens", ",", "customize", ")", ":", "is_pypy", "=", "False", "# For a rough break out on the first word. This may", "# include instructions that don't need customization,", "# but we'll do a finer check after the rough breakout.", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
decompile
ingests and deparses a given code block 'co' if `bytecode_version` is None, use the current Python intepreter version. Caller is responsible for closing `out` and `mapstream`
uncompyle6/main.py
def decompile( bytecode_version, co, out=None, showasm=None, showast=False, timestamp=None, showgrammar=False, code_objects={}, source_size=None, is_pypy=None, magic_int=None, mapstream=None, do_fragments=False): """ ingests and deparses a given code block 'co' if `bytecode_...
def decompile( bytecode_version, co, out=None, showasm=None, showast=False, timestamp=None, showgrammar=False, code_objects={}, source_size=None, is_pypy=None, magic_int=None, mapstream=None, do_fragments=False): """ ingests and deparses a given code block 'co' if `bytecode_...
[ "ingests", "and", "deparses", "a", "given", "code", "block", "co" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/main.py#L47-L120
[ "def", "decompile", "(", "bytecode_version", ",", "co", ",", "out", "=", "None", ",", "showasm", "=", "None", ",", "showast", "=", "False", ",", "timestamp", "=", "None", ",", "showgrammar", "=", "False", ",", "code_objects", "=", "{", "}", ",", "sourc...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
decompile_file
decompile Python byte-code file (.pyc). Return objects to all of the deparsed objects found in `filename`.
uncompyle6/main.py
def decompile_file(filename, outstream=None, showasm=None, showast=False, showgrammar=False, mapstream=None, do_fragments=False): """ decompile Python byte-code file (.pyc). Return objects to all of the deparsed objects found in `filename`. """ filename = check_object_path(filena...
def decompile_file(filename, outstream=None, showasm=None, showast=False, showgrammar=False, mapstream=None, do_fragments=False): """ decompile Python byte-code file (.pyc). Return objects to all of the deparsed objects found in `filename`. """ filename = check_object_path(filena...
[ "decompile", "Python", "byte", "-", "code", "file", "(", ".", "pyc", ")", ".", "Return", "objects", "to", "all", "of", "the", "deparsed", "objects", "found", "in", "filename", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/main.py#L138-L165
[ "def", "decompile_file", "(", "filename", ",", "outstream", "=", "None", ",", "showasm", "=", "None", ",", "showast", "=", "False", ",", "showgrammar", "=", "False", ",", "mapstream", "=", "None", ",", "do_fragments", "=", "False", ")", ":", "filename", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
main
in_base base directory for input files out_base base directory for output files (ignored when files list of filenames to be uncompyled (relative to in_base) outfile write output to this filename (overwrites out_base) For redirecting output to - <filename> outfile=<filename> (out_base is ignored) ...
uncompyle6/main.py
def main(in_base, out_base, compiled_files, source_files, outfile=None, showasm=None, showast=False, do_verify=False, showgrammar=False, raise_on_error=False, do_linemaps=False, do_fragments=False): """ in_base base directory for input files out_base base directory for output file...
def main(in_base, out_base, compiled_files, source_files, outfile=None, showasm=None, showast=False, do_verify=False, showgrammar=False, raise_on_error=False, do_linemaps=False, do_fragments=False): """ in_base base directory for input files out_base base directory for output file...
[ "in_base", "base", "directory", "for", "input", "files", "out_base", "base", "directory", "for", "output", "files", "(", "ignored", "when", "files", "list", "of", "filenames", "to", "be", "uncompyled", "(", "relative", "to", "in_base", ")", "outfile", "write",...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/main.py#L169-L347
[ "def", "main", "(", "in_base", ",", "out_base", ",", "compiled_files", ",", "source_files", ",", "outfile", "=", "None", ",", "showasm", "=", "None", ",", "showast", "=", "False", ",", "do_verify", "=", "False", ",", "showgrammar", "=", "False", ",", "ra...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
make_function3_annotate
Dump function defintion, doc string, and function body. This code is specialized for Python 3
uncompyle6/semantics/make_function.py
def make_function3_annotate(self, node, is_lambda, nested=1, code_node=None, annotate_last=-1): """ Dump function defintion, doc string, and function body. This code is specialized for Python 3""" def build_param(ast, name, default): """build parameters: ...
def make_function3_annotate(self, node, is_lambda, nested=1, code_node=None, annotate_last=-1): """ Dump function defintion, doc string, and function body. This code is specialized for Python 3""" def build_param(ast, name, default): """build parameters: ...
[ "Dump", "function", "defintion", "doc", "string", "and", "function", "body", ".", "This", "code", "is", "specialized", "for", "Python", "3" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/make_function.py#L38-L283
[ "def", "make_function3_annotate", "(", "self", ",", "node", ",", "is_lambda", ",", "nested", "=", "1", ",", "code_node", "=", "None", ",", "annotate_last", "=", "-", "1", ")", ":", "def", "build_param", "(", "ast", ",", "name", ",", "default", ")", ":"...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
make_function2
Dump function defintion, doc string, and function body. This code is specialied for Python 2.
uncompyle6/semantics/make_function.py
def make_function2(self, node, is_lambda, nested=1, code_node=None): """ Dump function defintion, doc string, and function body. This code is specialied for Python 2. """ # FIXME: call make_function3 if we are self.version >= 3.0 # and then simplify the below. def build_param(ast, name, de...
def make_function2(self, node, is_lambda, nested=1, code_node=None): """ Dump function defintion, doc string, and function body. This code is specialied for Python 2. """ # FIXME: call make_function3 if we are self.version >= 3.0 # and then simplify the below. def build_param(ast, name, de...
[ "Dump", "function", "defintion", "doc", "string", "and", "function", "body", ".", "This", "code", "is", "specialied", "for", "Python", "2", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/make_function.py#L285-L443
[ "def", "make_function2", "(", "self", ",", "node", ",", "is_lambda", ",", "nested", "=", "1", ",", "code_node", "=", "None", ")", ":", "# FIXME: call make_function3 if we are self.version >= 3.0", "# and then simplify the below.", "def", "build_param", "(", "ast", ","...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
make_function3
Dump function definition, doc string, and function body in Python version 3.0 and above
uncompyle6/semantics/make_function.py
def make_function3(self, node, is_lambda, nested=1, code_node=None): """Dump function definition, doc string, and function body in Python version 3.0 and above """ # For Python 3.3, the evaluation stack in MAKE_FUNCTION is: # * default argument objects in positional order # * pairs of name a...
def make_function3(self, node, is_lambda, nested=1, code_node=None): """Dump function definition, doc string, and function body in Python version 3.0 and above """ # For Python 3.3, the evaluation stack in MAKE_FUNCTION is: # * default argument objects in positional order # * pairs of name a...
[ "Dump", "function", "definition", "doc", "string", "and", "function", "body", "in", "Python", "version", "3", ".", "0", "and", "above" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/make_function.py#L446-L845
[ "def", "make_function3", "(", "self", ",", "node", ",", "is_lambda", ",", "nested", "=", "1", ",", "code_node", "=", "None", ")", ":", "# For Python 3.3, the evaluation stack in MAKE_FUNCTION is:", "# * default argument objects in positional order", "# * pairs of name and def...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
cmp_code_objects
Compare two code-objects. This is the main part of this module.
uncompyle6/verify.py
def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, verify, name=''): """ Compare two code-objects. This is the main part of this module. """ # print code_obj1, type(code_obj2) assert iscode(code_obj1), \ "cmp_code_object first object type is %s, not code" % ...
def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, verify, name=''): """ Compare two code-objects. This is the main part of this module. """ # print code_obj1, type(code_obj2) assert iscode(code_obj1), \ "cmp_code_object first object type is %s, not code" % ...
[ "Compare", "two", "code", "-", "objects", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/verify.py#L150-L362
[ "def", "cmp_code_objects", "(", "version", ",", "is_pypy", ",", "code_obj1", ",", "code_obj2", ",", "verify", ",", "name", "=", "''", ")", ":", "# print code_obj1, type(code_obj2)", "assert", "iscode", "(", "code_obj1", ")", ",", "\"cmp_code_object first object type...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
compare_code_with_srcfile
Compare a .pyc with a source code file. If everything is okay, None is returned. Otherwise a string message describing the mismatch is returned.
uncompyle6/verify.py
def compare_code_with_srcfile(pyc_filename, src_filename, verify): """Compare a .pyc with a source code file. If everything is okay, None is returned. Otherwise a string message describing the mismatch is returned. """ (version, timestamp, magic_int, code_obj1, is_pypy, source_size) = load_module(p...
def compare_code_with_srcfile(pyc_filename, src_filename, verify): """Compare a .pyc with a source code file. If everything is okay, None is returned. Otherwise a string message describing the mismatch is returned. """ (version, timestamp, magic_int, code_obj1, is_pypy, source_size) = load_module(p...
[ "Compare", "a", ".", "pyc", "with", "a", "source", "code", "file", ".", "If", "everything", "is", "okay", "None", "is", "returned", ".", "Otherwise", "a", "string", "message", "describing", "the", "mismatch", "is", "returned", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/verify.py#L390-L415
[ "def", "compare_code_with_srcfile", "(", "pyc_filename", ",", "src_filename", ",", "verify", ")", ":", "(", "version", ",", "timestamp", ",", "magic_int", ",", "code_obj1", ",", "is_pypy", ",", "source_size", ")", "=", "load_module", "(", "pyc_filename", ")", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
compare_files
Compare two .pyc files.
uncompyle6/verify.py
def compare_files(pyc_filename1, pyc_filename2, verify): """Compare two .pyc files.""" (version1, timestamp, magic_int1, code_obj1, is_pypy, source_size) = uncompyle6.load_module(pyc_filename1) (version2, timestamp, magic_int2, code_obj2, is_pypy, source_size) = uncompyle6.load_module(pyc_filen...
def compare_files(pyc_filename1, pyc_filename2, verify): """Compare two .pyc files.""" (version1, timestamp, magic_int1, code_obj1, is_pypy, source_size) = uncompyle6.load_module(pyc_filename1) (version2, timestamp, magic_int2, code_obj2, is_pypy, source_size) = uncompyle6.load_module(pyc_filen...
[ "Compare", "two", ".", "pyc", "files", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/verify.py#L417-L425
[ "def", "compare_files", "(", "pyc_filename1", ",", "pyc_filename2", ",", "verify", ")", ":", "(", "version1", ",", "timestamp", ",", "magic_int1", ",", "code_obj1", ",", "is_pypy", ",", "source_size", ")", "=", "uncompyle6", ".", "load_module", "(", "pyc_filen...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
code_deparse
Convert the code object co into a python source fragment. :param version: The python version this code is from as a float, for example 2.6, 2.7, 3.2, 3.3, 3.4, 3.5 etc. :param co: The code object to parse. :param out: File like object to write th...
uncompyle6/semantics/fragments.py
def code_deparse(co, out=StringIO(), version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', walker=FragmentsWalker): """ Convert the code object co into a python source fragment. :param version: The python ...
def code_deparse(co, out=StringIO(), version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS, code_objects={}, compile_mode='exec', walker=FragmentsWalker): """ Convert the code object co into a python source fragment. :param version: The python ...
[ "Convert", "the", "code", "object", "co", "into", "a", "python", "source", "fragment", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1755-L1848
[ "def", "code_deparse", "(", "co", ",", "out", "=", "StringIO", "(", ")", ",", "version", "=", "None", ",", "is_pypy", "=", "None", ",", "debug_opts", "=", "DEFAULT_DEBUG_OPTS", ",", "code_objects", "=", "{", "}", ",", "compile_mode", "=", "'exec'", ",", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
code_deparse_around_offset
Like deparse_code(), but given a function/module name and offset, finds the node closest to offset. If offset is not an instruction boundary, we raise an IndexError.
uncompyle6/semantics/fragments.py
def code_deparse_around_offset(name, offset, co, out=StringIO(), version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS): """ Like deparse_code(), but given a function/module name and offset, finds the node closest to offset. If offset is not...
def code_deparse_around_offset(name, offset, co, out=StringIO(), version=None, is_pypy=None, debug_opts=DEFAULT_DEBUG_OPTS): """ Like deparse_code(), but given a function/module name and offset, finds the node closest to offset. If offset is not...
[ "Like", "deparse_code", "()", "but", "given", "a", "function", "/", "module", "name", "and", "offset", "finds", "the", "node", "closest", "to", "offset", ".", "If", "offset", "is", "not", "an", "instruction", "boundary", "we", "raise", "an", "IndexError", ...
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1858-L1884
[ "def", "code_deparse_around_offset", "(", "name", ",", "offset", ",", "co", ",", "out", "=", "StringIO", "(", ")", ",", "version", "=", "None", ",", "is_pypy", "=", "None", ",", "debug_opts", "=", "DEFAULT_DEBUG_OPTS", ")", ":", "assert", "iscode", "(", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
op_at_code_loc
Return the instruction name at code[loc] using opc to look up instruction names. Returns 'got IndexError' if code[loc] is invalid. `code` is instruction bytecode, `loc` is an offset (integer) and `opc` is an opcode module from `xdis`.
uncompyle6/semantics/fragments.py
def op_at_code_loc(code, loc, opc): """Return the instruction name at code[loc] using opc to look up instruction names. Returns 'got IndexError' if code[loc] is invalid. `code` is instruction bytecode, `loc` is an offset (integer) and `opc` is an opcode module from `xdis`. """ try: ...
def op_at_code_loc(code, loc, opc): """Return the instruction name at code[loc] using opc to look up instruction names. Returns 'got IndexError' if code[loc] is invalid. `code` is instruction bytecode, `loc` is an offset (integer) and `opc` is an opcode module from `xdis`. """ try: ...
[ "Return", "the", "instruction", "name", "at", "code", "[", "loc", "]", "using", "opc", "to", "look", "up", "instruction", "names", ".", "Returns", "got", "IndexError", "if", "code", "[", "loc", "]", "is", "invalid", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1898-L1910
[ "def", "op_at_code_loc", "(", "code", ",", "loc", ",", "opc", ")", ":", "try", ":", "op", "=", "code", "[", "loc", "]", "except", "IndexError", ":", "return", "'got IndexError'", "return", "opc", ".", "opname", "[", "op", "]" ]
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
deparsed_find
Return a NodeInfo nametuple for a fragment-deparsed `deparsed` at `tup`. `tup` is a name and offset tuple, `deparsed` is a fragment object and `code` is instruction bytecode.
uncompyle6/semantics/fragments.py
def deparsed_find(tup, deparsed, code): """Return a NodeInfo nametuple for a fragment-deparsed `deparsed` at `tup`. `tup` is a name and offset tuple, `deparsed` is a fragment object and `code` is instruction bytecode. """ nodeInfo = None name, last_i = tup if (name, last_i) in deparsed.offsets....
def deparsed_find(tup, deparsed, code): """Return a NodeInfo nametuple for a fragment-deparsed `deparsed` at `tup`. `tup` is a name and offset tuple, `deparsed` is a fragment object and `code` is instruction bytecode. """ nodeInfo = None name, last_i = tup if (name, last_i) in deparsed.offsets....
[ "Return", "a", "NodeInfo", "nametuple", "for", "a", "fragment", "-", "deparsed", "deparsed", "at", "tup", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1912-L1931
[ "def", "deparsed_find", "(", "tup", ",", "deparsed", ",", "code", ")", ":", "nodeInfo", "=", "None", "name", ",", "last_i", "=", "tup", "if", "(", "name", ",", "last_i", ")", "in", "deparsed", ".", "offsets", ".", "keys", "(", ")", ":", "nodeInfo", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.table_r_node
General pattern where the last node should should get the text span attributes of the entire tree
uncompyle6/semantics/fragments.py
def table_r_node(self, node): """General pattern where the last node should should get the text span attributes of the entire tree""" start = len(self.f.getvalue()) try: self.default(node) except GenericASTTraversalPruningException: final = len(self.f.getv...
def table_r_node(self, node): """General pattern where the last node should should get the text span attributes of the entire tree""" start = len(self.f.getvalue()) try: self.default(node) except GenericASTTraversalPruningException: final = len(self.f.getv...
[ "General", "pattern", "where", "the", "last", "node", "should", "should", "get", "the", "text", "span", "attributes", "of", "the", "entire", "tree" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L208-L218
[ "def", "table_r_node", "(", "self", ",", "node", ")", ":", "start", "=", "len", "(", "self", ".", "f", ".", "getvalue", "(", ")", ")", "try", ":", "self", ".", "default", "(", "node", ")", "except", "GenericASTTraversalPruningException", ":", "final", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.n_exec_stmt
exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT
uncompyle6/semantics/fragments.py
def n_exec_stmt(self, node): """ exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT """ start = len(self.f.getvalue()) + len(self.indent) try: super(FragmentsWalker, self).n_exec_stmt(node) except GenericASTTraversalPru...
def n_exec_stmt(self, node): """ exec_stmt ::= expr exprlist DUP_TOP EXEC_STMT exec_stmt ::= expr exprlist EXEC_STMT """ start = len(self.f.getvalue()) + len(self.indent) try: super(FragmentsWalker, self).n_exec_stmt(node) except GenericASTTraversalPru...
[ "exec_stmt", "::", "=", "expr", "exprlist", "DUP_TOP", "EXEC_STMT", "exec_stmt", "::", "=", "expr", "exprlist", "EXEC_STMT" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L425-L437
[ "def", "n_exec_stmt", "(", "self", ",", "node", ")", ":", "start", "=", "len", "(", "self", ".", "f", ".", "getvalue", "(", ")", ")", "+", "len", "(", "self", ".", "indent", ")", "try", ":", "super", "(", "FragmentsWalker", ",", "self", ")", ".",...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.n_list_comp
List comprehensions
uncompyle6/semantics/fragments.py
def n_list_comp(self, node): """List comprehensions""" p = self.prec self.prec = 27 n = node[-1] assert n == 'list_iter' # find innermost node while n == 'list_iter': n = n[0] # recurse one step if n == 'list_for': n = n[3] el...
def n_list_comp(self, node): """List comprehensions""" p = self.prec self.prec = 27 n = node[-1] assert n == 'list_iter' # find innermost node while n == 'list_iter': n = n[0] # recurse one step if n == 'list_for': n = n[3] el...
[ "List", "comprehensions" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L578-L599
[ "def", "n_list_comp", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "n", "=", "node", "[", "-", "1", "]", "assert", "n", "==", "'list_iter'", "# find innermost node", "while", "n", "==", "'list_ite...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.comprehension_walk3
List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code.
uncompyle6/semantics/fragments.py
def comprehension_walk3(self, node, iter_index, code_index=-5): """ List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = node[co...
def comprehension_walk3(self, node, iter_index, code_index=-5): """ List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = node[co...
[ "List", "comprehensions", "the", "way", "they", "are", "done", "in", "Python3", ".", "They", "re", "more", "other", "comprehensions", "e", ".", "g", ".", "set", "comprehensions", "See", "if", "we", "can", "combine", "code", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L660-L784
[ "def", "comprehension_walk3", "(", "self", ",", "node", ",", "iter_index", ",", "code_index", "=", "-", "5", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "node", "[", "code_index", "]", ".", "attr", "assert", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.setcomprehension_walk3
List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code.
uncompyle6/semantics/fragments.py
def setcomprehension_walk3(self, node, collection_index): """List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Code(node[1].attr, se...
def setcomprehension_walk3(self, node, collection_index): """List comprehensions the way they are done in Python3. They're more other comprehensions, e.g. set comprehensions See if we can combine code. """ p = self.prec self.prec = 27 code = Code(node[1].attr, se...
[ "List", "comprehensions", "the", "way", "they", "are", "done", "in", "Python3", ".", "They", "re", "more", "other", "comprehensions", "e", ".", "g", ".", "set", "comprehensions", "See", "if", "we", "can", "combine", "code", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L927-L978
[ "def", "setcomprehension_walk3", "(", "self", ",", "node", ",", "collection_index", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "27", "code", "=", "Code", "(", "node", "[", "1", "]", ".", "attr", ",", "self", ".", "scanner", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.fixup_parents
Make sure each node has a parent
uncompyle6/semantics/fragments.py
def fixup_parents(self, node, parent): """Make sure each node has a parent""" start, finish = 0, self.last_finish # We assume anything with a start has a finish. needs_range = not hasattr(node, 'start') if not hasattr(node, 'parent'): node.parent = parent fo...
def fixup_parents(self, node, parent): """Make sure each node has a parent""" start, finish = 0, self.last_finish # We assume anything with a start has a finish. needs_range = not hasattr(node, 'start') if not hasattr(node, 'parent'): node.parent = parent fo...
[ "Make", "sure", "each", "node", "has", "a", "parent" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1157-L1180
[ "def", "fixup_parents", "(", "self", ",", "node", ",", "parent", ")", ":", "start", ",", "finish", "=", "0", ",", "self", ".", "last_finish", "# We assume anything with a start has a finish.", "needs_range", "=", "not", "hasattr", "(", "node", ",", "'start'", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.fixup_offsets
Adjust all offsets under node
uncompyle6/semantics/fragments.py
def fixup_offsets(self, new_start, node): """Adjust all offsets under node""" if hasattr(node, 'start'): node.start += new_start node.finish += new_start for n in node: if hasattr(n, 'offset'): if hasattr(n, 'start'): n.star...
def fixup_offsets(self, new_start, node): """Adjust all offsets under node""" if hasattr(node, 'start'): node.start += new_start node.finish += new_start for n in node: if hasattr(n, 'offset'): if hasattr(n, 'start'): n.star...
[ "Adjust", "all", "offsets", "under", "node" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1185-L1197
[ "def", "fixup_offsets", "(", "self", ",", "new_start", ",", "node", ")", ":", "if", "hasattr", "(", "node", ",", "'start'", ")", ":", "node", ".", "start", "+=", "new_start", "node", ".", "finish", "+=", "new_start", "for", "n", "in", "node", ":", "i...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.set_pos_info_recurse
Set positions under node
uncompyle6/semantics/fragments.py
def set_pos_info_recurse(self, node, start, finish, parent=None): """Set positions under node""" self.set_pos_info(node, start, finish) if parent is None: parent = node for n in node: n.parent = parent if hasattr(n, 'offset'): self.set_...
def set_pos_info_recurse(self, node, start, finish, parent=None): """Set positions under node""" self.set_pos_info(node, start, finish) if parent is None: parent = node for n in node: n.parent = parent if hasattr(n, 'offset'): self.set_...
[ "Set", "positions", "under", "node" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1199-L1212
[ "def", "set_pos_info_recurse", "(", "self", ",", "node", ",", "start", ",", "finish", ",", "parent", "=", "None", ")", ":", "self", ".", "set_pos_info", "(", "node", ",", "start", ",", "finish", ")", "if", "parent", "is", "None", ":", "parent", "=", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.n_dict
prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42 }"
uncompyle6/semantics/fragments.py
def n_dict(self, node): """ prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42 }" """ p = self.prec self.prec = 100 self.indent_more(INDENT_PER_LEVEL) line_seperator = ',\n' + self.indent sep = INDENT_PER_LEVEL[:-1] start = l...
def n_dict(self, node): """ prettyprint a dict 'dict' is something like k = {'a': 1, 'b': 42 }" """ p = self.prec self.prec = 100 self.indent_more(INDENT_PER_LEVEL) line_seperator = ',\n' + self.indent sep = INDENT_PER_LEVEL[:-1] start = l...
[ "prettyprint", "a", "dict", "dict", "is", "something", "like", "k", "=", "{", "a", ":", "1", "b", ":", "42", "}" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1412-L1502
[ "def", "n_dict", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "100", "self", ".", "indent_more", "(", "INDENT_PER_LEVEL", ")", "line_seperator", "=", "',\\n'", "+", "self", ".", "indent", "sep", "=", "I...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.n_list
prettyprint a list or tuple
uncompyle6/semantics/fragments.py
def n_list(self, node): """ prettyprint a list or tuple """ p = self.prec self.prec = 100 n = node.pop() lastnode = n.kind start = len(self.f.getvalue()) if lastnode.startswith('BUILD_LIST'): self.write('['); endchar = ']' elif ...
def n_list(self, node): """ prettyprint a list or tuple """ p = self.prec self.prec = 100 n = node.pop() lastnode = n.kind start = len(self.f.getvalue()) if lastnode.startswith('BUILD_LIST'): self.write('['); endchar = ']' elif ...
[ "prettyprint", "a", "list", "or", "tuple" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1504-L1564
[ "def", "n_list", "(", "self", ",", "node", ")", ":", "p", "=", "self", ".", "prec", "self", ".", "prec", "=", "100", "n", "=", "node", ".", "pop", "(", ")", "lastnode", "=", "n", ".", "kind", "start", "=", "len", "(", "self", ".", "f", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
FragmentsWalker.template_engine
The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on.
uncompyle6/semantics/fragments.py
def template_engine(self, entry, startnode): """The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on. """ # print("-----") # print(startnode) # print(en...
def template_engine(self, entry, startnode): """The format template interpetation engine. See the comment at the beginning of this module for the how we interpret format specifications such as %c, %C, and so on. """ # print("-----") # print(startnode) # print(en...
[ "The", "format", "template", "interpetation", "engine", ".", "See", "the", "comment", "at", "the", "beginning", "of", "this", "module", "for", "the", "how", "we", "interpret", "format", "specifications", "such", "as", "%c", "%C", "and", "so", "on", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/fragments.py#L1568-L1724
[ "def", "template_engine", "(", "self", ",", "entry", ",", "startnode", ")", ":", "# print(\"-----\")", "# print(startnode)", "# print(entry[0])", "# print('======')", "startnode_start", "=", "len", "(", "self", ".", "f", ".", "getvalue", "(", ")", ")", "start", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
LineMapWalker.write
Augment write routine to keep track of current line
uncompyle6/semantics/linemap.py
def write(self, *data): """Augment write routine to keep track of current line""" for l in data: ## print("XXX write: '%s'" % l) for i in str(l): if i == '\n': self.current_line_number += 1 pass pass ...
def write(self, *data): """Augment write routine to keep track of current line""" for l in data: ## print("XXX write: '%s'" % l) for i in str(l): if i == '\n': self.current_line_number += 1 pass pass ...
[ "Augment", "write", "routine", "to", "keep", "track", "of", "current", "line" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/linemap.py#L25-L35
[ "def", "write", "(", "self", ",", "*", "data", ")", ":", "for", "l", "in", "data", ":", "## print(\"XXX write: '%s'\" % l)", "for", "i", "in", "str", "(", "l", ")", ":", "if", "i", "==", "'\\n'", ":", "self", ".", "current_line_number", "+=", "1", "p...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
LineMapWalker.default
Augment write default routine to record line number changes
uncompyle6/semantics/linemap.py
def default(self, node): """Augment write default routine to record line number changes""" if hasattr(node, 'linestart'): if node.linestart: self.source_linemap[self.current_line_number] = node.linestart return super(LineMapWalker, self).default(node)
def default(self, node): """Augment write default routine to record line number changes""" if hasattr(node, 'linestart'): if node.linestart: self.source_linemap[self.current_line_number] = node.linestart return super(LineMapWalker, self).default(node)
[ "Augment", "write", "default", "routine", "to", "record", "line", "number", "changes" ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/linemap.py#L39-L44
[ "def", "default", "(", "self", ",", "node", ")", ":", "if", "hasattr", "(", "node", ",", "'linestart'", ")", ":", "if", "node", ".", "linestart", ":", "self", ".", "source_linemap", "[", "self", ".", "current_line_number", "]", "=", "node", ".", "lines...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
Scanner26.ingest
Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 'Token's. The transformations are made to assist the deparsing grammar. Specificially: - various types of LOAD_CONST's are categorized in terms of what they load - COME_FRO...
uncompyle6/scanners/scanner26.py
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 'Token's. The transformations are made to assist the deparsing grammar. Specificially: - vario...
def ingest(self, co, classname=None, code_objects={}, show_asm=None): """ Pick out tokens from an uncompyle6 code object, and transform them, returning a list of uncompyle6 'Token's. The transformations are made to assist the deparsing grammar. Specificially: - vario...
[ "Pick", "out", "tokens", "from", "an", "uncompyle6", "code", "object", "and", "transform", "them", "returning", "a", "list", "of", "uncompyle6", "Token", "s", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/scanners/scanner26.py#L52-L282
[ "def", "ingest", "(", "self", ",", "co", ",", "classname", "=", "None", ",", "code_objects", "=", "{", "}", ",", "show_asm", "=", "None", ")", ":", "if", "not", "show_asm", ":", "show_asm", "=", "self", ".", "show_asm", "bytecode", "=", "self", ".", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0
train
find_all_globals
Search Syntax Tree node to find variable names that are global.
uncompyle6/semantics/helper.py
def find_all_globals(node, globs): """Search Syntax Tree node to find variable names that are global.""" for n in node: if isinstance(n, SyntaxTree): globs = find_all_globals(n, globs) elif n.kind in read_write_global_ops: globs.add(n.pattr) return globs
def find_all_globals(node, globs): """Search Syntax Tree node to find variable names that are global.""" for n in node: if isinstance(n, SyntaxTree): globs = find_all_globals(n, globs) elif n.kind in read_write_global_ops: globs.add(n.pattr) return globs
[ "Search", "Syntax", "Tree", "node", "to", "find", "variable", "names", "that", "are", "global", "." ]
rocky/python-uncompyle6
python
https://github.com/rocky/python-uncompyle6/blob/c5d7944e657f0ad05a0e2edd34e1acb27001abc0/uncompyle6/semantics/helper.py#L21-L28
[ "def", "find_all_globals", "(", "node", ",", "globs", ")", ":", "for", "n", "in", "node", ":", "if", "isinstance", "(", "n", ",", "SyntaxTree", ")", ":", "globs", "=", "find_all_globals", "(", "n", ",", "globs", ")", "elif", "n", ".", "kind", "in", ...
c5d7944e657f0ad05a0e2edd34e1acb27001abc0