Пример #1
0
    def __call__(self):
        astnode = self.model.astnode
        if isinstance(astnode, _ast.Name) or isinstance(astnode, _ast.Attribute):
            #the case where the decorator has no parameters
            if not getattr(astnode, 'id', None):
                # XXX: added by phil because sometimes astnode.id is None
                astnode.id = get_dotted_name_from_astnode(astnode)
            self.model.decoratorname = astnode.id
            self.model._decoratorname_orgin = astnode.id
            return

        #the decorator has parameters
        self.model.is_callable=True
        if not getattr(astnode.func, 'id', None):
            astnode.func.id=get_dotted_name_from_astnode(astnode.func)

        self.model.decoratorname = astnode.func.id
        self.model._decoratorname_orgin = astnode.func.id
        self._parseastargs(astnode)
        self.model._args_orgin = copy.deepcopy(self.model.args)
        self.model._kwargs_orgin = copy.deepcopy(self.model.kwargs)
Пример #2
0
 def __call__(self):
     astnode = self.model.astnode
     for target in astnode.targets:
         if isinstance(target, _ast.Tuple):
             for name in target.elts:
                 self.model.targets.append(name.id)
         elif isinstance(target, _ast.Subscript):
             self.model.targets.append(get_dotted_name_from_astnode(target.value))
         else:
             try:
                 self.model.targets.append(target.id)
             except AttributeError:
                 self.model.targets.append(target.value.id)
                 
     self.model._targets_orgin = copy.deepcopy(self.model.targets)
     self._findattributeend()
     self._extractvalue()
     self._parseastargs(astnode)
     self.model._args_orgin = copy.deepcopy(self.model.args)
     self.model._kwargs_orgin = copy.deepcopy(self.model.kwargs)