本文整理汇总了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
示例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)
示例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')
示例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)
示例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')
示例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, [])