Python symbol.funcdef() Examples
The following are 30
code examples of symbol.funcdef().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
symbol
, or try the search function
.
Example #1
Source File: transformer.py From ironpython2 with Apache License 2.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #2
Source File: transformer.py From medicare-demo with Apache License 2.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #3
Source File: transformer.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #4
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #5
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #6
Source File: function_definition.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def Annotate(cls, symbol_type, children): if symbol_type != symbol.stmt: return None compound_statement = children[0] if compound_statement.type != symbol.compound_stmt: return None statement = compound_statement.children[0] if statement.type == symbol.funcdef: return cls(statement.type, statement.children) elif (statement.type == symbol.decorated and statement.children[-1].type == symbol.funcdef): return cls(statement.type, statement.children) else: return None
Example #7
Source File: function_definition.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def Annotate(cls, symbol_type, children): if symbol_type != symbol.stmt: return None compound_statement = children[0] if compound_statement.type != symbol.compound_stmt: return None statement = compound_statement.children[0] if statement.type == symbol.funcdef: return cls(statement.type, statement.children) elif (statement.type == symbol.decorated and statement.children[-1].type == symbol.funcdef): return cls(statement.type, statement.children) else: return None
Example #8
Source File: function_definition.py From Jandroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
def Annotate(cls, symbol_type, children): if symbol_type != symbol.stmt: return None compound_statement = children[0] if compound_statement.type != symbol.compound_stmt: return None statement = compound_statement.children[0] if statement.type == symbol.funcdef: return cls(statement.type, statement.children) elif (statement.type == symbol.decorated and statement.children[-1].type == symbol.funcdef): return cls(statement.type, statement.children) else: return None
Example #9
Source File: getdocs.py From pycopia with Apache License 2.0 | 6 votes |
def _extract_info(self, tree): # extract docstring if len(tree) == 2: found, vars = match(DOCSTRING_STMT_PATTERN[1], tree[1]) else: found, vars = match(DOCSTRING_STMT_PATTERN, tree[3]) if found: self._docstring = eval(vars['docstring']) # discover inner definitions for node in tree[1:]: found, vars = match(COMPOUND_STMT_PATTERN, node) if found: cstmt = vars['compound'] if cstmt[0] == symbol.funcdef: name = cstmt[2][1] self._function_info[name] = FunctionInfo(cstmt) elif cstmt[0] == symbol.classdef: name = cstmt[2][1] self._class_info[name] = ClassInfo(cstmt)
Example #10
Source File: transformer.py From oss-ftp with MIT License | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #11
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #12
Source File: transformer.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #13
Source File: transformer.py From BinderFilter with MIT License | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #14
Source File: transformer.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def compile_node(self, node): ### emit a line-number node? n = node[0] if n == symbol.encoding_decl: self.encoding = node[2] node = node[1] n = node[0] if n == symbol.single_input: return self.single_input(node[1:]) if n == symbol.file_input: return self.file_input(node[1:]) if n == symbol.eval_input: return self.eval_input(node[1:]) if n == symbol.lambdef: return self.lambdef(node[1:]) if n == symbol.funcdef: return self.funcdef(node[1:]) if n == symbol.classdef: return self.classdef(node[1:]) raise WalkerError, ('unexpected node type', n)
Example #15
Source File: log.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def _loadfile(self, fileno): try: filename = self._filemap[fileno] except KeyError: print "Could not identify fileId", fileno return 1 if filename is None: return 1 absname = os.path.normcase(os.path.join(self.cwd, filename)) try: fp = open(absname) except IOError: return st = parser.suite(fp.read()) fp.close() # Scan the tree looking for def and lambda nodes, filling in # self._funcmap with all the available information. funcdef = symbol.funcdef lambdef = symbol.lambdef stack = [st.totuple(1)] while stack: tree = stack.pop() try: sym = tree[0] except (IndexError, TypeError): continue if sym == funcdef: self._funcmap[(fileno, tree[2][2])] = filename, tree[2][1] elif sym == lambdef: self._funcmap[(fileno, tree[1][2])] = filename, "<lambda>" stack.extend(list(tree[1:]))
Example #16
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #17
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def decorated(self, nodelist): assert nodelist[0][0] == symbol.decorators if nodelist[1][0] == symbol.funcdef: n = [nodelist[0]] + list(nodelist[1][1:]) return self.funcdef(n) elif nodelist[1][0] == symbol.classdef: decorators = self.decorators(nodelist[0][1:]) cls = self.classdef(nodelist[1][1:]) cls.decorators = decorators return cls raise WalkerError()
Example #18
Source File: transformer.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #19
Source File: transformer.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #20
Source File: transformer.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #21
Source File: log.py From ironpython2 with Apache License 2.0 | 5 votes |
def _loadfile(self, fileno): try: filename = self._filemap[fileno] except KeyError: print "Could not identify fileId", fileno return 1 if filename is None: return 1 absname = os.path.normcase(os.path.join(self.cwd, filename)) try: fp = open(absname) except IOError: return st = parser.suite(fp.read()) fp.close() # Scan the tree looking for def and lambda nodes, filling in # self._funcmap with all the available information. funcdef = symbol.funcdef lambdef = symbol.lambdef stack = [st.totuple(1)] while stack: tree = stack.pop() try: sym = tree[0] except (IndexError, TypeError): continue if sym == funcdef: self._funcmap[(fileno, tree[2][2])] = filename, tree[2][1] elif sym == lambdef: self._funcmap[(fileno, tree[1][2])] = filename, "<lambda>" stack.extend(list(tree[1:]))
Example #22
Source File: transformer.py From medicare-demo with Apache License 2.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #23
Source File: transformer.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #24
Source File: transformer.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #25
Source File: transformer.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def decorated(self, nodelist): assert nodelist[0][0] == symbol.decorators if nodelist[1][0] == symbol.funcdef: n = [nodelist[0]] + list(nodelist[1][1:]) return self.funcdef(n) elif nodelist[1][0] == symbol.classdef: decorators = self.decorators(nodelist[0][1:]) cls = self.classdef(nodelist[1][1:]) cls.decorators = decorators return cls raise WalkerError()
Example #26
Source File: log.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _loadfile(self, fileno): try: filename = self._filemap[fileno] except KeyError: print "Could not identify fileId", fileno return 1 if filename is None: return 1 absname = os.path.normcase(os.path.join(self.cwd, filename)) try: fp = open(absname) except IOError: return st = parser.suite(fp.read()) fp.close() # Scan the tree looking for def and lambda nodes, filling in # self._funcmap with all the available information. funcdef = symbol.funcdef lambdef = symbol.lambdef stack = [st.totuple(1)] while stack: tree = stack.pop() try: sym = tree[0] except (IndexError, TypeError): continue if sym == funcdef: self._funcmap[(fileno, tree[2][2])] = filename, tree[2][1] elif sym == lambdef: self._funcmap[(fileno, tree[1][2])] = filename, "<lambda>" stack.extend(list(tree[1:]))
Example #27
Source File: log.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _loadfile(self, fileno): try: filename = self._filemap[fileno] except KeyError: print "Could not identify fileId", fileno return 1 if filename is None: return 1 absname = os.path.normcase(os.path.join(self.cwd, filename)) try: fp = open(absname) except IOError: return st = parser.suite(fp.read()) fp.close() # Scan the tree looking for def and lambda nodes, filling in # self._funcmap with all the available information. funcdef = symbol.funcdef lambdef = symbol.lambdef stack = [st.totuple(1)] while stack: tree = stack.pop() try: sym = tree[0] except (IndexError, TypeError): continue if sym == funcdef: self._funcmap[(fileno, tree[2][2])] = filename, tree[2][1] elif sym == lambdef: self._funcmap[(fileno, tree[1][2])] = filename, "<lambda>" stack.extend(list(tree[1:]))
Example #28
Source File: recipe-576404.py From code with MIT License | 5 votes |
def _get_forbidden_symbols(): """ Returns a list of symbol codes representing statements that are *not* wanted in configuration files. """ try: # Python 2.5: symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt, symbol.decorator, symbol.decorators, symbol.eval_input, symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt, symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef, symbol.global_stmt, symbol.import_as_name, symbol.import_as_names, symbol.import_from, symbol.import_name, symbol.import_stmt, symbol.lambdef, symbol.old_lambdef, symbol.print_stmt, symbol.raise_stmt, symbol.try_stmt, symbol.while_stmt, symbol.with_stmt, symbol.with_var, symbol.yield_stmt, symbol.yield_expr] except AttributeError: # Python 2.4: symlst = [symbol.break_stmt, symbol.classdef, symbol.continue_stmt, symbol.decorator, symbol.decorators, symbol.eval_input, symbol.except_clause, symbol.exec_stmt, symbol.flow_stmt, symbol.for_stmt, symbol.fpdef, symbol.fplist, symbol.funcdef, symbol.global_stmt, symbol.import_as_name, symbol.import_as_names, symbol.import_from, symbol.import_name, symbol.import_stmt, symbol.lambdef, symbol.print_stmt, symbol.raise_stmt, symbol.try_stmt, symbol.while_stmt] return symlst
Example #29
Source File: transformer.py From oss-ftp with MIT License | 5 votes |
def funcdef(self, nodelist): # -6 -5 -4 -3 -2 -1 # funcdef: [decorators] 'def' NAME parameters ':' suite # parameters: '(' [varargslist] ')' if len(nodelist) == 6: assert nodelist[0][0] == symbol.decorators decorators = self.decorators(nodelist[0][1:]) else: assert len(nodelist) == 5 decorators = None lineno = nodelist[-4][2] name = nodelist[-4][1] args = nodelist[-3][2] if args[0] == symbol.varargslist: names, defaults, flags = self.com_arglist(args[1:]) else: names = defaults = () flags = 0 doc = self.get_docstring(nodelist[-1]) # code for function code = self.com_node(nodelist[-1]) if doc is not None: assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] return Function(decorators, name, names, defaults, flags, doc, code, lineno=lineno)
Example #30
Source File: transformer.py From oss-ftp with MIT License | 5 votes |
def decorated(self, nodelist): assert nodelist[0][0] == symbol.decorators if nodelist[1][0] == symbol.funcdef: n = [nodelist[0]] + list(nodelist[1][1:]) return self.funcdef(n) elif nodelist[1][0] == symbol.classdef: decorators = self.decorators(nodelist[0][1:]) cls = self.classdef(nodelist[1][1:]) cls.decorators = decorators return cls raise WalkerError()