Python functools.WRAPPER_UPDATES() Examples

The following are code examples for showing how to use functools.WRAPPER_UPDATES(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: Python_Study   Author: thsheep   File: functiontools.py    (license) View Source Project 6 votes vote down vote up
def test_update_wraper():
    print(functools.WRAPPER_ASSIGNMENTS)
    print(functools.WRAPPER_UPDATES)
    
    hello()
    print(hello.__name__)
    print(hello.__doc__)

    print
    hello2()
    print(hello2.__name__)
    print(hello2.__doc__)


# 3. wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)
# ??partial(update_wrapper, wrapped=wrapped, assigned=assigned, updated=updated)??? 
Example 2
Project: python-   Author: secondtonone1   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 3
Project: python-   Author: secondtonone1   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 4
Project: python-   Author: secondtonone1   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 5
Project: my-first-blog   Author: AnkurBegining   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 6
Project: my-first-blog   Author: AnkurBegining   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 7
Project: my-first-blog   Author: AnkurBegining   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 8
Project: my-first-blog   Author: AnkurBegining   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 9
Project: cbapi-python   Author: carbonblack   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 10
Project: googletranslate.popclipext   Author: wizyoung   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 11
Project: oscars2016   Author: 0x0ece   File: six.py    (Apache License 2.0) View Source Project 5 votes vote down vote up
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 
Example 12
Project: Projects   Author: it2school   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 13
Project: pip-update-requirements   Author: alanhamlett   File: six.py    (BSD 2-Clause "Simplified" License) View Source Project 5 votes vote down vote up
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 
Example 14
Project: pip-update-requirements   Author: alanhamlett   File: six.py    (BSD 2-Clause "Simplified" License) View Source Project 5 votes vote down vote up
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 
Example 15
Project: Splunk_CBER_App   Author: MHaggis   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 16
Project: swjtu-pyscraper   Author: Desgard   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 17
Project: swjtu-pyscraper   Author: Desgard   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 18
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 19
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 20
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 21
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 22
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 23
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 24
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 25
Project: noc-orchestrator   Author: DirceuSilvaLabs   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 26
Project: bambi   Author: bambinos   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 27
Project: jira_worklog_scanner   Author: pgarneau   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 28
Project: jira_worklog_scanner   Author: pgarneau   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 29
Project: jira_worklog_scanner   Author: pgarneau   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 30
Project: jira_worklog_scanner   Author: pgarneau   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 31
Project: workflows.kyoyue   Author: wizyoung   File: six.py    (MIT License) View Source Project 5 votes vote down vote up
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 
Example 32
Project: CodingDojo   Author: ComputerSocietyUNB   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 33
Project: zanph   Author: zanph   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 34
Project: zanph   Author: zanph   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 35
Project: hostapd-mana   Author: adde88   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 36
Project: GAMADV-XTD   Author: taers232c   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 37
Project: deb-python-pint   Author: openstack   File: registry.py    (license) View Source Project 5 votes vote down vote up
def with_context(self, name, **kw):
        """Decorator to wrap a function call in a Pint context.

        Use it to ensure that a certain context is active when
        calling a function::

            >>> @ureg.with_context('sp')
            ... def my_cool_fun(wavelenght):
            ...     print('This wavelength is equivalent to: %s', wavelength.to('terahertz'))


        :param names: name of the context.
        :param kwargs: keyword arguments for the contexts.
        :return: the wrapped function.
        """
        def decorator(func):
            assigned = tuple(attr for attr in functools.WRAPPER_ASSIGNMENTS if hasattr(func, attr))
            updated = tuple(attr for attr in functools.WRAPPER_UPDATES if hasattr(func, attr))

            @functools.wraps(func, assigned=assigned, updated=updated)
            def wrapper(*values, **kwargs):
                with self.context(name, **kw):
                    return func(*values, **kwargs)

            return wrapper

        return decorator 
Example 38
Project: deb-python-pint   Author: openstack   File: registry_helpers.py    (license) View Source Project 5 votes vote down vote up
def check(ureg, *args):
    """Decorator to for quantity type checking for function inputs.

    Use it to ensure that the decorated function input parameters match
    the expected type of pint quantity.

    Use None to skip argument checking.

    :param ureg: a UnitRegistry instance.
    :param args: iterable of input units.
    :return: the wrapped function.
    :raises:
        :class:`DimensionalityError` if the parameters don't match dimensions
    """
    dimensions = [ureg.get_dimensionality(dim) if dim is not None else None for dim in args]

    def decorator(func):
        assigned = tuple(attr for attr in functools.WRAPPER_ASSIGNMENTS if hasattr(func, attr))
        updated = tuple(attr for attr in functools.WRAPPER_UPDATES if hasattr(func, attr))

        @functools.wraps(func, assigned=assigned, updated=updated)
        def wrapper(*values, **kwargs):
            for dim, value in zip_longest(dimensions, values):

                if dim is None:
                    continue

                val_dim = ureg.get_dimensionality(value)
                if val_dim != dim:
                    raise DimensionalityError(value, 'a quantity of',
                                              val_dim, dim)
            return func(*values, **kwargs)
        return wrapper
    return decorator 
Example 39
Project: Sci-Finder   Author: snverse   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 40
Project: Sci-Finder   Author: snverse   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 41
Project: Sci-Finder   Author: snverse   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 42
Project: Sci-Finder   Author: snverse   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 43
Project: Sci-Finder   Author: snverse   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 44
Project: auger   Author: laffra   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 45
Project: purelove   Author: hucmosin   File: six.py    (license) View Source Project 5 votes vote down vote up
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
              updated=functools.WRAPPER_UPDATES):
        def wrapper(f):
            f = functools.wraps(wrapped)(f)
            f.__wrapped__ = wrapped
            return f
        return wrapper 
Example 46
Project: purelove   Author: hucmosin   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 47
Project: harbour-sailfinder   Author: DylanVanAssche   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 48
Project: harbour-sailfinder   Author: DylanVanAssche   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 49
Project: harbour-sailfinder   Author: DylanVanAssche   File: six.py    (license) View Source Project 5 votes vote down vote up
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 
Example 50
Project: harbour-sailfinder   Author: DylanVanAssche   File: six.py    (license) View Source Project 5 votes vote down vote up
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