How to use the wirerope.Wire function in wirerope

To help you get started, we’ve selected a few wirerope examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github youknowone / ring / ring / func / base.py View on Github external
class Config(object):
    coder = attr.ib()
    user_interface = attr.ib()
    storage_backend = attr.ib()
    storage_class = attr.ib()
    miss_value = attr.ib()
    default_action = attr.ib()
    key_encoding = attr.ib()
    expire_default = attr.ib()
    key_refactor = attr.ib()
    key_prefix = attr.ib()
    ignorable_keys = attr.ib()
    # wire_class = attr.ib()


class RingWire(Wire):

    __slots__ = ()

    def __init__(self, rope, *args, **kwargs):
        super(RingWire, self).__init__(rope, *args, **kwargs)

    @property
    def storage(self):
        return self._rope.storage

    def encode(self, v):
        return self._rope.encode(v)

    def decode(self, v):
        return self._rope.decode(v)
github youknowone / methodtools / methodtools.py View on Github external
__all__ = 'lru_cache',


if hasattr(functools, 'lru_cache'):
    _functools_lru_cache = functools.lru_cache
else:
    try:
        import functools32
    except ImportError:
        # raise AttributeError about fallback failure
        functools.lru_cache  # install `functools32` to run on py2
    else:
        _functools_lru_cache = functools32.lru_cache


class _LruCacheWire(Wire):

    def __init__(self, rope, *args, **kwargs):
        super(_LruCacheWire, self).__init__(rope, *args, **kwargs)
        lru_args, lru_kwargs = rope._args
        wrapper = _functools_lru_cache(
            *lru_args, **lru_kwargs)(self.__func__)
        self.__call__ = wrapper
        self.cache_clear = wrapper.cache_clear
        self.cache_info = wrapper.cache_info

    def __call__(self, *args, **kwargs):
        # descriptor detection support - never called
        return self.__call__(*args, **kwargs)

    def _on_property(self):
        return self.__call__()

wirerope

'Turn functions and methods into fully controllable objects'

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis