本文整理汇总了Python中logilab.astng.MANAGER.astng_from_module方法的典型用法代码示例。如果您正苦于以下问题:Python MANAGER.astng_from_module方法的具体用法?Python MANAGER.astng_from_module怎么用?Python MANAGER.astng_from_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logilab.astng.MANAGER
的用法示例。
在下文中一共展示了MANAGER.astng_from_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: builtin_lookup
# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module [as 别名]
def builtin_lookup(name):
"""lookup a name into the builtin module
return the list of matching statements and the astng for the builtin
module
"""
builtinastng = MANAGER.astng_from_module(__builtin__)
if name == '__dict__':
return builtinastng, ()
try:
stmts = builtinastng.locals[name]
except KeyError:
stmts = ()
return builtinastng, stmts
示例2: add_ormobject
# 需要导入模块: from logilab.astng import MANAGER [as 别名]
# 或者: from logilab.astng.MANAGER import astng_from_module [as 别名]
def add_ormobject(self, orm_type, orm_name):
if orm_type in dt.done:
return
dt.done.add(orm_type)
module_name = orm_type.__module__
pymodule = namedAny(module_name)
assert pymodule
module = MANAGER.astng_from_module(pymodule)
assert module
class_node = module[orm_name]
t = ''
t += 'class %s:\n' % (orm_name, )
t += ' q = None\n'
t += ' _connection = None\n'
orm_ti = dt.orm_classes.get(orm_name)
if orm_ti is not None:
for name in sorted(orm_ti.get_column_names()):
t += ' %s = None\n' % (name, )
for name, class_name in sorted(orm_ti.get_foreign_columns()):
self.add_ormobject(dt.orm_classes[class_name].orm_type,
class_name)
t += ' %s = None\n' % (class_name, )
t += ' %s = %s()\n' % (name, class_name)
for name, class_name in sorted(orm_ti.get_single_joins()):
self.add_ormobject(
dt.orm_classes[class_name].orm_type,
class_name)
t += ' %s = %s()\n' % (name, class_name)
t += '\n'
nodes = self.builder.string_build(t)
for key, value in nodes[orm_name].items():
class_node.locals[key] = [value]