Ejemplo n.º 1
0
 def __init__(self, stream=sys.stdout, debug=False):
     self.v = lambda tree, visitor=self: walk(tree, visitor)
     self.stream = stream
     self.strcode = ""
     self.debug = debug
     self.indents = 0
     ASTVisitor.__init__(self)
Ejemplo n.º 2
0
    def __init__(self, stream=sys.stdout, parent=None, debug=False):

        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug = debug
        self.indents = 0

        self.ids = {}
        self.ids['global'] = [
            'abs', 'str', 'ord', 'True', 'False', 'robot', 'pygame', 'list',
            'range', 'RoboException', 'None', 'int', 'float', 'zip', 'arange',
            'sin', 'array', 'resize', 'pi', 'RoboThread', '__clock__'
        ]
        self.ids['__fn__'] = []
        self.ids[''] = []

        self.fn_types = {}
        self.fn_type_regex = re.compile(":param \((.*?)\)")

        self.var_types = {}
        self.var_types['global'] = {}

        self.fn = ""
        ASTVisitor.__init__(self)
Ejemplo n.º 3
0
    def __init__(self, stream=sys.stdout, parent=None, debug=False):
        
        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug = debug
        self.indents = 0

        self.ids = {}
        self.ids['global'] = ['abs', 'str', 'ord', 'True', 'False', 'robot', 
                                'pygame', 'list', 'range', 'RoboException', 
                                'None', 'int', 'float', 'zip', 'arange', 
                                'sin', 'array', 'resize', 'pi']
        self.ids['__fn__'] = []
        self.ids[''] = []

        self.fn_types = {}
        self.fn_type_regex = re.compile(":param \((.*?)\)")

        self.var_types = {}
        self.var_types['global'] = {}

        self.fn = ""
        ASTVisitor.__init__(self)
Ejemplo n.º 4
0
 def __init__(self, stream=sys.stdout, debug=False):
     self.v = lambda tree, visitor=self: walk(tree, visitor)
     self.stream = stream
     self.strcode = ""
     self.debug = debug
     self.indents = 0
     ASTVisitor.__init__(self)
Ejemplo n.º 5
0
    def __init__(self, ast, stats=None, description=None):
        ASTVisitor.__init__(self)
        if isinstance(ast, basestring):
            ast = compiler.parse(ast)

        self.stats = stats or Stats(description or '<module>')
        for child in ast.getChildNodes():
            compiler.walk(child, self, walker=self)
Ejemplo n.º 6
0
    def __init__(self, ast, stats=None, description=None):
        ASTVisitor.__init__(self)
        if isinstance(ast, basestring):
            ast = compiler.parse(ast)

        self.stats = stats or Stats(description or '<module>')
        for child in ast.getChildNodes():
            compiler.walk(child, self, walker=self)
Ejemplo n.º 7
0
    def __init__(self, ast):
        ASTVisitor.__init__(self)
        if isinstance(ast, basestring):
            ast = compiler.parse(ast)

        self.stats = Stats(ast.name)
        for child in ast.getChildNodes():
            compiler.walk(child, self, walker=self)
Ejemplo n.º 8
0
 def __init__(self, stream=None):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     self.v = lambda tree, visitor=self: walk(tree, visitor)
     ASTVisitor.__init__(self)
Ejemplo n.º 9
0
 def __init__(self, stream=None, comments={}):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     self.comments = comments
     #self.v = lambda tree, visitor=self: walk(tree, visitor)
     self.v = self._visit
     ASTVisitor.__init__(self)
Ejemplo n.º 10
0
	def __init__( self, ast, stats=None, title=None ):
		ASTVisitor.__init__(self)
		
		if isinstance( ast, basestring ):
			ast = compiler.parse( ast )
		
		self.stats = stats or Stats( title or '<unnamed>' )
		
		for child in ast.getChildNodes():
			compiler.walk( child, self, walker=self )
Ejemplo n.º 11
0
 def __init__(self, code, stats=None, description=None):
     ASTVisitor.__init__(self)
     ast = compiler.parse(code)
     self.node_types = set()
     self.visit_node(ast.node)
     #for child in ast.getChildNodes():
         #compiler.walk(child, self, walker=self)
     all_types = set(line.strip()
                     for line
                     in file('python_ast_node_types.txt').readlines())
     self.untouched_nodes = sorted(all_types - self.node_types)
Ejemplo n.º 12
0
 def __init__(self, stream=None):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     # self.v = lambda tree, visitor=self: print tree.lineno; walk(tree, visitor)
     ASTVisitor.__init__(self)
     self.line_map = {}
     self.line = 1
     self.to_write = ""
Ejemplo n.º 13
0
 def __init__(self, stream=None):
     if stream is None:
         self.stream = sys.stdout
     else:
         self.stream = stream
     self.indents = 0
     # self.v = lambda tree, visitor=self: print tree.lineno; walk(tree, visitor)
     ASTVisitor.__init__(self)
     self.line_map = {}
     self.line = 1
     self.to_write = ""
Ejemplo n.º 14
0
 def __init__(self, code, stats=None, description=None):
     ASTVisitor.__init__(self)
     ast = compiler.parse(code)
     self.node_types = set()
     self.visit_node(ast.node)
     #for child in ast.getChildNodes():
     #compiler.walk(child, self, walker=self)
     all_types = set(
         line.strip()
         for line in file('python_ast_node_types.txt').readlines())
     self.untouched_nodes = sorted(all_types - self.node_types)
Ejemplo n.º 15
0
    def __init__(self, package, types, docformat):
        """Create an ASGTranslator.

        package: enclosing package the generated modules are to be part of."""

        ASTVisitor.__init__(self)
        self.scope = package and [package] or []
        self.file = None
        self.types = types
        self.attributes = []
        self.any_type = ASG.BuiltinTypeId('Python',QName('',))
        self.docformat = docformat
        self.documentable = None
        self.name = QName()
        self.imports = []
Ejemplo n.º 16
0
    def __init__(self, stream=sys.stdout, parent=None, debug=False):

        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug = debug
        self.indents = 0

        self.ids = {}
        self.ids["global"] = [
            "abs",
            "str",
            "ord",
            "True",
            "False",
            "robot",
            "pygame",
            "list",
            "range",
            "RoboException",
            "None",
            "int",
            "float",
            "zip",
            "arange",
            "sin",
            "array",
            "resize",
            "pi",
            "RoboThread",
            "__clock__",
        ]
        self.ids["__fn__"] = []
        self.ids[""] = []

        self.fn_types = {}
        self.fn_type_regex = re.compile(":param \((.*?)\)")

        self.var_types = {}
        self.var_types["global"] = {}

        self.fn = ""
        ASTVisitor.__init__(self)
Ejemplo n.º 17
0
    def __init__(self, stream=sys.stdout, parent=None, debug=False):
        
        self.parent = parent

        self.v = lambda tree, visitor=self: walk(tree, visitor)
        self.stream = stream
        self.strcode = ""
        self.debug=debug
        self.indents = 0

        self.ids = {}
        self.ids['global'] = ['abs', 'str', 'ord', 'True', 'False', 'robot', 
                                'pygame', 'list', 'range', 'RoboException', 
                                'None']
        self.ids['__fn__'] = []
        self.ids[''] = []

        self.fn = ""
        ASTVisitor.__init__(self)
Ejemplo n.º 18
0
	def __init__(self, modulename, outstream):
		ASTVisitor.__init__(self)
		self.module = modulename.split('.')[-1]
		self.out = outstream
		self.opdict = {	'<' : '__lt__', '<=':'__le__', '==':'__eq__', 
					'!=':'__ne__', '>':'__gt__', '>=':'__ge__', 
					'is':'is_', 'is not':'is_not', 'in':'__contains__',
					'+=':'__add__', '&=':'__and__', '/=':'__div__', '//=':'__floordiv__',
					'<<=':'__lshift__', '%=':'__mod__', '*=':'__mul__',
					'|=':'__or__','**=':'__pow__', '>>=':'__rshift__','-=':'__sub__',
					'^=':'__xor__'}
		self.funcVargs = 4
		self.funcKargs = 8
		self.freeVarName = "lambda" #Python keyword so won't be in use
		self.freeVar = 1 #Free var index
		self.freeUsedVars = []
		self.classes = [] #classes defined in this module
		self.functions = [] #functions defined in this module
		self.vars = [] #top level vars in this module
		self.modules = [] #imported modules
		self.imports = {} #imported functions/modules
		self.deps = []
		self.toplevel = True
Ejemplo n.º 19
0
 def default(self, node, *args):
     """Default node handler."""
     raise NotSupportedNode(node.__class__)
     return ASTVisitor.default(self, node)
Ejemplo n.º 20
0
 def __init__(self):
     # no super, ASTVisitor is old style class
     ASTVisitor.__init__(self)
     self.functions = []
     self.exports = []
Ejemplo n.º 21
0
 def default(self, node, *args):
     self._visitor.default(node)
     ASTVisitor.default(self, node, *args)
Ejemplo n.º 22
0
 def __init__(self, visitor):
     ASTVisitor.__init__(self)
     self._visitor = visitor
Ejemplo n.º 23
0
 def __init__(self, node):
     ASTVisitor.__init__(self)
     self.score = 1
     self._in_conditional = False
     self.results = ComplexityResults()
     self.process_root_node(node)
Ejemplo n.º 24
0
 def default_visit(self, node, *args):
     ASTVisitor.default(self, node, *args)
Ejemplo n.º 25
0
 def __init__(self):
     ASTVisitor.__init__(self)
     self.children = []
Ejemplo n.º 26
0
 def __init__(self, visitor):
     ASTVisitor.__init__(self)
     self._visitor = visitor
Ejemplo n.º 27
0
 def __init__(self):
     ASTVisitor.__init__(self)
     self.statements = []
Ejemplo n.º 28
0
 def __init__(self):
     ASTVisitor.__init__(self)
     self.statements = []
Ejemplo n.º 29
0
 def __init__(self):
     ASTVisitor.__init__(self)
Ejemplo n.º 30
0
 def __init__(self, token_parser):
     ASTVisitor.__init__(self)
     self.token_parser = token_parser
     self.context = []
     self.documentable = None
Ejemplo n.º 31
0
 def default(self, node, *args):
     raise NotSupportedNode(node.__class__)
     return ASTVisitor.default(self, node)
Ejemplo n.º 32
0
 def __init__ (self,res):
     ASTVisitor.__init__(self)
     self.res=res
Ejemplo n.º 33
0
 def default(self, node, *args):
     self._visitor.default(node)
     ASTVisitor.default(self, node, *args) 
 def __init__(self, filename):
     ASTVisitor.__init__(self)
     self.xml = '<?xml version="1.0"?>\n\n'
     self.filename = filename
     self.indent_step = 2
     self.indent_val = 0
Ejemplo n.º 35
0
 def default_visit(self, node, *args):
     #print 'in default_visit (%s)' % node.__class__.__name__
     ASTVisitor.default(self, node, *args)
Ejemplo n.º 36
0
 def __init__(self, node):
     ASTVisitor.__init__(self)
     self.score = 1
     self._in_conditional = False
     self.results = ComplexityResults()
     self.process_root_node(node)