本文整理汇总了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