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


Python MANAGER.astng_from_module_name方法代码示例

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


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

示例1: import_module

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
 def import_module(self, modname, relative_only=False, level=None):
     """import the given module considering self as context"""
     try:
         absmodname = self.absolute_modname(modname, level)
         return MANAGER.astng_from_module_name(absmodname)
     except ASTNGBuildingException:
         # we only want to import a sub module or package of this module,
         # skip here
         if relative_only:
             raise
     module = MANAGER.astng_from_module_name(modname)
     return module
开发者ID:mozilla,项目名称:FlightDeck-lib,代码行数:14,代码来源:scoped_nodes.py

示例2: test_inspect_build0

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
 def test_inspect_build0(self):
     """test astng tree build from a living object"""
     builtin_astng = MANAGER.astng_from_module_name('__builtin__')
     fclass = builtin_astng['file']
     self.assert_('name' in fclass)
     self.assert_('mode' in fclass)
     self.assert_('read' in fclass)
     self.assert_(fclass.newstyle)
     self.assert_(fclass.pytype(), '__builtin__.type')
     self.assertIsInstance(fclass['read'], nodes.Function)
     # check builtin function has args.args == None
     dclass = builtin_astng['dict']
     self.assertEquals(dclass['has_key'].args.args, None)
     # just check type and object are there
     builtin_astng.getattr('type')
     builtin_astng.getattr('object')
     # check open file alias
     builtin_astng.getattr('open')
     # check 'help' is there (defined dynamically by site.py)
     builtin_astng.getattr('help')
     # check property has __init__
     pclass = builtin_astng['property']
     self.assert_('__init__' in pclass)
     self.assertIsInstance(builtin_astng['None'], nodes.Const)
     self.assertIsInstance(builtin_astng['True'], nodes.Const)
     self.assertIsInstance(builtin_astng['False'], nodes.Const)
     self.assertIsInstance(builtin_astng['Exception'], nodes.From)
     self.assertIsInstance(builtin_astng['NotImplementedError'], nodes.From)
开发者ID:AndryulE,项目名称:kitsune,代码行数:30,代码来源:unittest_builder.py

示例3: test_module_path

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
 def test_module_path(self):
     mod = m.astng_from_module_name('import_package_subpackage_module')
     package = mod.igetattr('package').next()
     self.failUnlessEqual(package.name, 'package')
     subpackage = package.igetattr('subpackage').next()
     self.failUnlessEqual(subpackage.name, 'package.subpackage')
     module = subpackage.igetattr('module').next()
     self.failUnlessEqual(module.name, 'package.subpackage.module')
开发者ID:mozilla,项目名称:FlightDeck-lib,代码行数:10,代码来源:regrtest.py

示例4: test_inspect_build_type_object

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
    def test_inspect_build_type_object(self):
        builtin_astng = MANAGER.astng_from_module_name('__builtin__')

        infered = list(builtin_astng.igetattr('object'))
        self.assertEquals(len(infered), 1)
        infered = infered[0]
        self.assertEquals(infered.name, 'object')
        as_string(infered)

        infered = list(builtin_astng.igetattr('type'))
        self.assertEquals(len(infered), 1)
        infered = infered[0]
        self.assertEquals(infered.name, 'type')
        as_string(infered)
开发者ID:AndryulE,项目名称:kitsune,代码行数:16,代码来源:unittest_builder.py

示例5: test_pylint_config_attr

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
 def test_pylint_config_attr(self):
     try:
         from pylint import lint
     except ImportError:
         self.skipTest('pylint not available')
     mod = MANAGER.astng_from_module_name('pylint.lint')
     pylinter = mod['PyLinter']
     expect = ['OptionsManagerMixIn', 'object', 'MessagesHandlerMixIn',
               'ReportsHandlerMixIn', 'BaseRawChecker', 'BaseChecker',
               'OptionsProviderMixIn', 'ASTWalker']
     self.assertListEqual([c.name for c in pylinter.ancestors()],
                          expect)
     self.assert_(list(Instance(pylinter).getattr('config')))
     infered = list(Instance(pylinter).igetattr('config'))
     self.assertEqual(len(infered), 1)
     self.assertEqual(infered[0].root().name, 'optparse')
     self.assertEqual(infered[0].name, 'Values')
开发者ID:Chaos99,项目名称:cachetools,代码行数:19,代码来源:unittest_regrtest.py

示例6: test_inspect_build1

# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module_name [as 别名]
 def test_inspect_build1(self):
     time_astng = MANAGER.astng_from_module_name('time')
     self.assert_(time_astng)
     self.assertEquals(time_astng['time'].args.defaults, [])
开发者ID:AndryulE,项目名称:kitsune,代码行数:6,代码来源:unittest_builder.py


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