本文整理匯總了Python中Cerebrum.Utils.this_module方法的典型用法代碼示例。如果您正苦於以下問題:Python Utils.this_module方法的具體用法?Python Utils.this_module怎麽用?Python Utils.this_module使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cerebrum.Utils
的用法示例。
在下文中一共展示了Utils.this_module方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wrapper
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import this_module [as 別名]
def wrapper(cls):
# Make the API exceptions available
for name in API_EXCEPTION_NAMES:
base = getattr(Utils.this_module(), name)
setattr(cls, name, base)
# The type constructors provided by the driver module should
# be accessible as (static) methods of the database's
# connection objects.
for ctor_name in API_TYPE_CTOR_NAMES:
if hasattr(cls, ctor_name):
# There already is an implementation of this
# particular ctor in this class, probably for a good
# reason (e.g. the driver module doesn't supply this
# type ctor); skip to next ctor.
continue
f = getattr(module, ctor_name)
setattr(cls, ctor_name, staticmethod(f))
# Likewise we copy the driver-specific type objects to the
# connection object's class.
for type_name in API_TYPE_NAMES:
if hasattr(cls, type_name):
# Already present as attribute; skip.
continue
type_obj = getattr(module, type_name)
setattr(cls, type_name, type_obj)
# Set up a "bind parameter converter" suitable for the driver
# module's `paramstyle' constant.
if getattr(cls, 'param_converter', None) is None:
cls.param_converter = get_converter(module.paramstyle)
# make the real db module available as db-mod
cls._db_mod = module
return cls
示例2: this_module_test
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import this_module [as 別名]
def this_module_test():
""" Utils.this_module reports correct module. """
me = sys.modules[this_module_test.__module__]
assert Utils.this_module() is me
assert Utils.this_module() == me