當前位置: 首頁>>代碼示例>>Python>>正文


Python astutil.ASTTransformer類代碼示例

本文整理匯總了Python中genshi.template.astutil.ASTTransformer的典型用法代碼示例。如果您正苦於以下問題:Python ASTTransformer類的具體用法?Python ASTTransformer怎麽用?Python ASTTransformer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ASTTransformer類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: visit_Attribute

    def visit_Attribute(self, node):
        if not isinstance(node.ctx, _ast.Load):
            return ASTTransformer.visit_Attribute(self, node)

        func = _new(_ast.Name, '_lookup_attr', _ast.Load())
        args = [self.visit(node.value), _new(_ast.Str, node.attr)]
        return _new(_ast.Call, func, args, [])
開發者ID:anandu,項目名稱:pylibs,代碼行數:7,代碼來源:eval.py

示例2: visit_Subscript

    def visit_Subscript(self, node):
        if not isinstance(node.ctx, _ast.Load) or not isinstance(node.slice, _ast.Index):
            return ASTTransformer.visit_Subscript(self, node)

        func = _new(_ast.Name, "_lookup_item", _ast.Load())
        args = [self.visit(node.value), _new(_ast.Tuple, (self.visit(node.slice.value),), _ast.Load())]
        return _new(_ast.Call, func, args, [])
開發者ID:ntulip,項目名稱:tweetapp,代碼行數:7,代碼來源:eval.py

示例3: visit_ClassDef

 def visit_ClassDef(self, node):
     if len(self.locals) > 1:
         self.locals[-1].add(node.name)
     self.locals.append(set())
     try:
         return ASTTransformer.visit_ClassDef(self, node)
     finally:
         self.locals.pop()
開發者ID:anandu,項目名稱:pylibs,代碼行數:8,代碼來源:eval.py

示例4: visit_FunctionDef

    def visit_FunctionDef(self, node):
        if len(self.locals) > 1:
            self.locals[-1].add(node.name)

        self.locals.append(self._extract_names(node.args))
        try:
            return ASTTransformer.visit_FunctionDef(self, node)
        finally:
            self.locals.pop()
開發者ID:anandu,項目名稱:pylibs,代碼行數:9,代碼來源:eval.py

示例5: visit_ImportFrom

 def visit_ImportFrom(self, node):
     if [a.name for a in node.names] == ['*']:
         if has_star_import_bug:
             # This is a Python 2.4 bug. Only if we have a broken Python
             # version do we need to apply this hack
             node = _new(_ast.Expr, _new(_ast.Call,
                 _new(_ast.Name, '_star_import_patch'), [
                     _new(_ast.Name, '__data__'),
                     _new(_ast.Str, node.module)
                 ], (), ()))
         return node
     if len(self.locals) > 1:
         self.locals[-1].update(self._extract_names(node))
     return ASTTransformer.visit_ImportFrom(self, node)
開發者ID:anandu,項目名稱:pylibs,代碼行數:14,代碼來源:eval.py

示例6: visit_Lambda

 def visit_Lambda(self, node):
     self.locals.append(self._extract_names(node.args))
     try:
         return ASTTransformer.visit_Lambda(self, node)
     finally:
         self.locals.pop()
開發者ID:anandu,項目名稱:pylibs,代碼行數:6,代碼來源:eval.py

示例7: visit_Import

 def visit_Import(self, node):
     if len(self.locals) > 1:
         self.locals[-1].update(self._extract_names(node))
     return ASTTransformer.visit_Import(self, node)
開發者ID:anandu,項目名稱:pylibs,代碼行數:4,代碼來源:eval.py

示例8: visit_For

 def visit_For(self, node):
     self.locals.append(set())
     try:
         return ASTTransformer.visit_For(self, node)
     finally:
         self.locals.pop()
開發者ID:ntulip,項目名稱:tweetapp,代碼行數:6,代碼來源:eval.py


注:本文中的genshi.template.astutil.ASTTransformer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。