本文整理匯總了Python中functools.WRAPPER_ASSIGNMENTS屬性的典型用法代碼示例。如果您正苦於以下問題:Python functools.WRAPPER_ASSIGNMENTS屬性的具體用法?Python functools.WRAPPER_ASSIGNMENTS怎麽用?Python functools.WRAPPER_ASSIGNMENTS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類functools
的用法示例。
在下文中一共展示了functools.WRAPPER_ASSIGNMENTS屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_wrapper
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import WRAPPER_ASSIGNMENTS [as 別名]
def update_wrapper(wrapper,
wrapped,
assigned = functools.WRAPPER_ASSIGNMENTS,
updated = functools.WRAPPER_UPDATES):
"""
Patch two bugs in functools.update_wrapper.
"""
# workaround for http://bugs.python.org/issue3445
assigned = tuple(attr for attr in assigned if hasattr(wrapped, attr))
wrapper = functools.update_wrapper(wrapper, wrapped, assigned, updated)
# workaround for https://bugs.python.org/issue17482
wrapper.__wrapped__ = wrapped
return wrapper
示例2: wraps
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import WRAPPER_ASSIGNMENTS [as 別名]
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
def wrapper(f):
f = functools.wraps(wrapped, assigned, updated)(f)
f.__wrapped__ = wrapped
return f
return wrapper
示例3: _update_wrapper
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import WRAPPER_ASSIGNMENTS [as 別名]
def _update_wrapper(wrapper, wrapped,
assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
for attr in assigned:
try:
value = getattr(wrapped, attr)
except AttributeError:
continue
else:
setattr(wrapper, attr, value)
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
wrapper.__wrapped__ = wrapped
return wrapper
示例4: wraps
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import WRAPPER_ASSIGNMENTS [as 別名]
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES):
return functools.partial(_update_wrapper, wrapped=wrapped,
assigned=assigned, updated=updated)
示例5: wraps
# 需要導入模塊: import functools [as 別名]
# 或者: from functools import WRAPPER_ASSIGNMENTS [as 別名]
def wraps(
wrapped,
assigned=functools.WRAPPER_ASSIGNMENTS,
updated=functools.WRAPPER_UPDATES,
):
def wrapper(f):
f = functools.wraps(wrapped, assigned, updated)(f)
f.__wrapped__ = wrapped
return f
return wrapper