当前位置: 首页>>代码示例>>Python>>正文


Python ast.CallFunc方法代码示例

本文整理汇总了Python中compiler.ast.CallFunc方法的典型用法代码示例。如果您正苦于以下问题:Python ast.CallFunc方法的具体用法?Python ast.CallFunc怎么用?Python ast.CallFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在compiler.ast的用法示例。


在下文中一共展示了ast.CallFunc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getattr

# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import CallFunc [as 别名]
def _getattr(self, v, current_klass, use_getattr=False):
        attr_name = v.attrname
        if isinstance(v.expr, ast.Name):
            obj = self._name(v.expr, current_klass, return_none_for_module=True)
            if obj is None and v.expr.name in self.module_imports():
                # XXX TODO: distinguish between module import classes
                # and variables.  right now, this is a hack to get
                # the sys module working.
                # if v.expr.name == 'sys':
                return v.expr.name+'.'+attr_name
                # return v.expr.name+'.__'+attr_name+'.prototype.__class__'
            if not use_getattr or attr_name == '__class__' or \
                    attr_name == '__name__':
                return obj + "." + attr_name
            return "pyjslib.getattr(%s, '%s')" % (obj, attr_name)
        elif isinstance(v.expr, ast.Getattr):
            return self._getattr(v.expr, current_klass) + "." + attr_name
        elif isinstance(v.expr, ast.Subscript):
            return self._subscript(v.expr, self.modpfx()) + "." + attr_name
        elif isinstance(v.expr, ast.CallFunc):
            return self._callfunc(v.expr, self.modpfx()) + "." + attr_name
        else:
            raise TranslationError("unsupported type (in _getattr)", v.expr) 
开发者ID:thiagoralves,项目名称:OpenPLC_Editor,代码行数:25,代码来源:pyjs.py

示例2: getDeprecated

# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import CallFunc [as 别名]
def getDeprecated(self, decorators):
    """
    With a list of decorators, and the object it is running on, set the
    C{_deprecated_info} flag if any of the decorators are a Twisted deprecation
    decorator.
    """
    for a in decorators:
        if isinstance(a, ast.CallFunc):
            decorator = a.asList()

            # Getattr is used when the decorator is @foo.bar, not @bar
            if isinstance(decorator[0], ast.Getattr):
                getAttr = decorator[0].asList()
                name = getAttr[0].name
                fn = self.expandName(name) + "." + getAttr[1]
            else:
                fn = self.expandName(decorator[0].name)

            if fn == "twisted.python.deprecate.deprecated":
                try:
                    self._deprecated_info = deprecatedToUsefulText(
                        self.name, decorator)
                except AttributeError:
                    # It's a reference or something that we can't figure out
                    # from the AST.
                    pass 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:_pydoctor.py

示例3: _isNativeFunc

# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import CallFunc [as 别名]
def _isNativeFunc(self, node):
        if isinstance(node, ast.Discard):
            if isinstance(node.expr, ast.CallFunc):
                if isinstance(node.expr.node, ast.Name) and \
                       node.expr.node.name == NATIVE_JS_FUNC_NAME:
                    return True
        return False 
开发者ID:thiagoralves,项目名称:OpenPLC_Editor,代码行数:9,代码来源:pyjs.py

示例4: _discard

# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import CallFunc [as 别名]
def _discard(self, node, current_klass):

        if isinstance(node.expr, ast.CallFunc):
            debugStmt = self.debug and not self._isNativeFunc(node)
            if debugStmt and isinstance(node.expr.node, ast.Name) and \
               node.expr.node.name == 'import_wait':
                debugStmt = False
            if debugStmt:
                st = self.get_line_trace(node)
                self.printo("sys.addstack('%s');\n" % st)
            if isinstance(node.expr.node, ast.Name) and node.expr.node.name == NATIVE_JS_FUNC_NAME:
                if len(node.expr.args) != 1:
                    raise TranslationError("native javascript function %s must have one arg" % NATIVE_JS_FUNC_NAME, node.expr)
                if not isinstance(node.expr.args[0], ast.Const):
                    raise TranslationError("native javascript function %s must have constant arg" % NATIVE_JS_FUNC_NAME, node.expr)
                raw_js = node.expr.args[0].value
                self.printo(raw_js)
            else:
                expr = self._callfunc(node.expr, current_klass)
                self.printo("    " + expr + ";")

            if debugStmt:
                self.printo("sys.popstack();\n")

        elif isinstance(node.expr, ast.Const):
            if node.expr.value is not None:  # Empty statements generate ignore None
                self.printo(self._const(node.expr))
        else:
            raise TranslationError("unsupported type (in _discard)", node.expr) 
开发者ID:thiagoralves,项目名称:OpenPLC_Editor,代码行数:31,代码来源:pyjs.py

示例5: expr

# 需要导入模块: from compiler import ast [as 别名]
# 或者: from compiler.ast import CallFunc [as 别名]
def expr(self, node, current_klass):
        if isinstance(node, ast.Const):
            return self._const(node)
        # @@@ not sure if the parentheses should be here or in individual operator functions - JKT
        elif isinstance(node, ast.Mul):
            return " ( " + self._mul(node, current_klass) + " ) "
        elif isinstance(node, ast.Add):
            return " ( " + self._add(node, current_klass) + " ) "
        elif isinstance(node, ast.Sub):
            return " ( " + self._sub(node, current_klass) + " ) "
        elif isinstance(node, ast.Div):
            return " ( " + self._div(node, current_klass) + " ) "
        elif isinstance(node, ast.Mod):
            return self._mod(node, current_klass)
        elif isinstance(node, ast.UnaryAdd):
            return self._unaryadd(node, current_klass)
        elif isinstance(node, ast.UnarySub):
            return self._unarysub(node, current_klass)
        elif isinstance(node, ast.Not):
            return self._not(node, current_klass)
        elif isinstance(node, ast.Or):
            return self._or(node, current_klass)
        elif isinstance(node, ast.And):
            return self._and(node, current_klass)
        elif isinstance(node, ast.Invert):
            return self._invert(node, current_klass)
        elif isinstance(node, ast.Bitand):
            return "("+self._bitand(node, current_klass)+")"
        elif isinstance(node, ast.LeftShift):
            return self._bitshiftleft(node, current_klass)
        elif isinstance(node, ast.RightShift):
            return self._bitshiftright(node, current_klass)
        elif isinstance(node, ast.Bitxor):
            return "("+self._bitxor(node, current_klass)+")"
        elif isinstance(node, ast.Bitor):
            return "("+self._bitor(node, current_klass)+")"
        elif isinstance(node, ast.Compare):
            return self._compare(node, current_klass)
        elif isinstance(node, ast.CallFunc):
            return self._callfunc(node, current_klass)
        elif isinstance(node, ast.Name):
            return self._name(node, current_klass)
        elif isinstance(node, ast.Subscript):
            return self._subscript(node, current_klass)
        elif isinstance(node, ast.Getattr):
            return self._getattr(node, current_klass)
        elif isinstance(node, ast.List):
            return self._list(node, current_klass)
        elif isinstance(node, ast.Dict):
            return self._dict(node, current_klass)
        elif isinstance(node, ast.Tuple):
            return self._tuple(node, current_klass)
        elif isinstance(node, ast.Slice):
            return self._slice(node, current_klass)
        elif isinstance(node, ast.Lambda):
            return self._lambda(node, current_klass)
        else:
            raise TranslationError("unsupported type (in expr)", node) 
开发者ID:thiagoralves,项目名称:OpenPLC_Editor,代码行数:60,代码来源:pyjs.py


注:本文中的compiler.ast.CallFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。