本文整理汇总了Python中types.ModuleType.__getattribute__方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.__getattribute__方法的具体用法?Python ModuleType.__getattribute__怎么用?Python ModuleType.__getattribute__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.__getattribute__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getattribute__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattribute__(self, name):
modname = ModuleType.__getattribute__(self, 'modname')
logging.info(".......... fetching attr %r of module %r" % (name, modname))
if name == 'Request':
return ReplacementRequest
else:
return ModuleType.__getattribute__(self, name)
示例2: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in compat_modules:
if not self.__compat_installed__:
self.__compat_installed__ = True
from .__compat__ import install_compat_modules
install_compat_modules(self)
return ModuleType.__getattribute__(self, name)
示例3: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in object_origins:
module = __import__(object_origins[name], None, None, [name])
for extra_name in all_by_module[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
elif name in attribute_modules:
__import__('{}.{}'.format(PACKAGE_NAME, name))
return ModuleType.__getattribute__(self, name)
示例4: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in OBJECT_ORIGINS:
sub_module = __import__(OBJECT_ORIGINS[name], None, None, [name])
for extra_name in ALL_BY_MODULE[sub_module.__name__]:
setattr(self, extra_name, getattr(sub_module, extra_name))
return getattr(sub_module, name)
elif name in ATTRIBUTE_MODULES:
__import__('spyral.' + name)
return ModuleType.__getattribute__(self, name)
示例5: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in object_origins:
module = __import__(object_origins[name], None, None, [name])
for extra_name in objects[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
elif name in modules:
__import__('.'.join((modulename, name)))
return ModuleType.__getattribute__(self, name)
示例6: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in object_origins:
# 这一步完成动态加载
module = __import__(object_origins[name], None, None, [name])
# module中成员比较多 把需要的成员拎出来
for extra_name in all_by_module[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
elif name in attribute_modules:
__import__('werkzeug.' + name)
return ModuleType.__getattribute__(self, name)
示例7: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in self._object_origins:
module = __import__(self._object_origins[name], None, None, [name])
for item in self._all_by_module[module.__name__]:
setattr(self, item, getattr(module, item))
return getattr(module, name)
elif name in self._direct: # pragma: no cover
module = __import__(self._direct[name], None, None, [name])
setattr(self, name, module)
return module
return ModuleType.__getattribute__(self, name)
示例8: __getattribute__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattribute__(self, name):
o = ModuleType.__getattribute__(self, name)
if callable(o):
@functools.wraps(o)
def _localImportWrapper(*a, **kw):
__builtin__.__import__ = redirectLocalImports
try:
val = o(*a, **kw)
finally:
__builtin__.__import__ = _originalImport
return val
return _localImportWrapper
return o
示例9: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name == 'NestedAdmin':
warnings.warn(
"NestedAdmin has been changed to NestedModelAdmin",
NestedAdminPendingDeprecationWarning, stacklevel=2)
name = 'NestedModelAdmin'
if name in object_origins:
module = __import__(object_origins[name], None, None, [name])
for extra_name in all_by_module[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
elif name in attribute_modules:
__import__('nested_admin.' + name)
return ModuleType.__getattribute__(self, name)
示例10: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
origins = self._object_origins
if name in origins:
module = __import__(origins[name], None, None, [name])
for extra_name in self._all_by_module[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
elif name in self._direct:
module = __import__(self._direct[name], None, None, [name])
setattr(self, name, module)
return module
elif name in self._compat_modules:
setattr(self, name, get_compat(self.current_app, self, name))
return ModuleType.__getattribute__(self, name)
示例11: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, key):
if key in self.__pushed_up:
owner = self.__pushed_up[key]
value = getattr(getattr(self, owner), key)
setattr(self, key, value)
return value
elif key in self.__all__:
module = __import__(
self.__name__ + '.' + key, None, None, [self.__name__])
setattr(self, key, module)
return module
else:
try:
return ModuleType.__getattribute__(self, key)
except AttributeError:
raise AttributeError(
'module %r has no attribute %r' % (self.__name__, key))
示例12: __getattribute__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattribute__(self, name):
modname = ModuleType.__getattribute__(self, 'modname')
print ".......... fetching attr %r of module %r" % (name, modname)
return ModuleType.__getattribute__(self, name)
示例13: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, attr):
setattr(self, attr, Mock())
return ModuleType.__getattribute__(self, attr)
示例14: __getattr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __getattr__(self, name):
if name in compat_modules:
from .__compat__ import get_compat
setattr(self, name, get_compat(self.current_app, self, name))
return ModuleType.__getattribute__(self, name)
示例15: __repr__
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import __getattribute__ [as 别名]
def __repr__(self):
return "<lazy module %r>" % (ModuleType.__getattribute__(self, "__name__"),)