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


Python fixer_util.does_tree_import方法代码示例

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


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

示例1: try_with

# 需要导入模块: from lib2to3 import fixer_util [as 别名]
# 或者: from lib2to3.fixer_util import does_tree_import [as 别名]
def try_with(self, string):
        failing_tests = (("a", "a", "from a import b"),
                         ("a.d", "a", "from a.d import b"),
                         ("d.a", "a", "from d.a import b"),
                         (None, "a", "import b"),
                         (None, "a", "import b, c, d"))
        for package, name, import_ in failing_tests:
            n = self.does_tree_import(package, name, import_ + "\n" + string)
            self.assertFalse(n)
            n = self.does_tree_import(package, name, string + "\n" + import_)
            self.assertFalse(n)

        passing_tests = (("a", "a", "from a import a"),
                         ("x", "a", "from x import a"),
                         ("x", "a", "from x import b, c, a, d"),
                         ("x.b", "a", "from x.b import a"),
                         ("x.b", "a", "from x.b import b, c, a, d"),
                         (None, "a", "import a"),
                         (None, "a", "import b, c, a, d"))
        for package, name, import_ in passing_tests:
            n = self.does_tree_import(package, name, import_ + "\n" + string)
            self.assertTrue(n)
            n = self.does_tree_import(package, name, string + "\n" + import_)
            self.assertTrue(n) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:26,代码来源:test_util.py

示例2: does_tree_import

# 需要导入模块: from lib2to3 import fixer_util [as 别名]
# 或者: from lib2to3.fixer_util import does_tree_import [as 别名]
def does_tree_import(self, package, name, string):
        node = parse(string)
        # Find the binding of start -- that's what we'll go from
        node = self._find_bind_rec('start', node)
        return fixer_util.does_tree_import(package, name, node) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:test_util.py

示例3: transform

# 需要导入模块: from lib2to3 import fixer_util [as 别名]
# 或者: from lib2to3.fixer_util import does_tree_import [as 别名]
def transform(self, node, results):

        if does_tree_import('builtins', 'input', node):
            return

        return super(FixInput, self).transform(node, results) 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:8,代码来源:fix_input.py


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