diff options
author | 2015-08-26 18:16:09 +0300 | |
---|---|---|
committer | 2015-08-26 18:16:09 +0300 | |
commit | f8ac9d14a989c8cf1535e16165551dfa370b0b74 (patch) | |
tree | 43e396eb5d096ad74ec02afeccf8995a4d241a0f /external_libs/python/zmq/sugar/attrsettr.py | |
parent | cdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (diff) | |
parent | 53f0e28d7f30c7175cbb15884c309613593859d8 (diff) |
Merge branch 'master' into dan_stateless
Diffstat (limited to 'external_libs/python/zmq/sugar/attrsettr.py')
-rw-r--r-- | external_libs/python/zmq/sugar/attrsettr.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/external_libs/python/zmq/sugar/attrsettr.py b/external_libs/python/zmq/sugar/attrsettr.py deleted file mode 100644 index 4bbd36d6..00000000 --- a/external_libs/python/zmq/sugar/attrsettr.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding: utf-8 -"""Mixin for mapping set/getattr to self.set/get""" - -# Copyright (C) PyZMQ Developers -# Distributed under the terms of the Modified BSD License. - - -from . import constants - -class AttributeSetter(object): - - def __setattr__(self, key, value): - """set zmq options by attribute""" - - # regular setattr only allowed for class-defined attributes - for obj in [self] + self.__class__.mro(): - if key in obj.__dict__: - object.__setattr__(self, key, value) - return - - upper_key = key.upper() - try: - opt = getattr(constants, upper_key) - except AttributeError: - raise AttributeError("%s has no such option: %s" % ( - self.__class__.__name__, upper_key) - ) - else: - self._set_attr_opt(upper_key, opt, value) - - def _set_attr_opt(self, name, opt, value): - """override if setattr should do something other than call self.set""" - self.set(opt, value) - - def __getattr__(self, key): - """get zmq options by attribute""" - upper_key = key.upper() - try: - opt = getattr(constants, upper_key) - except AttributeError: - raise AttributeError("%s has no such option: %s" % ( - self.__class__.__name__, upper_key) - ) - else: - return self._get_attr_opt(upper_key, opt) - - def _get_attr_opt(self, name, opt): - """override if getattr should do something other than call self.get""" - return self.get(opt) - - -__all__ = ['AttributeSetter'] |