Mercurial > kallithea
changeset 8659:0f3fbd5fb9ea
lib: remove now unused class Oattr/OptionalAttr
Last usage was removed in previous commit.
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 09 Oct 2020 19:45:13 +0200 |
parents | 4791487dbec1 |
children | 9398244a2525 |
files | kallithea/lib/utils2.py kallithea/tests/api/api_base.py |
diffstat | 2 files changed, 0 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/utils2.py Fri Oct 09 19:43:18 2020 +0200 +++ b/kallithea/lib/utils2.py Fri Oct 09 19:45:13 2020 +0200 @@ -466,30 +466,6 @@ return None -class OptionalAttr(object): - """ - Special Optional Option that defines other attribute. Example:: - - def test(apiuser, userid=Optional(OAttr('apiuser')): - user = Optional.extract(userid) - # calls - - """ - - def __init__(self, attr_name): - self.attr_name = attr_name - - def __repr__(self): - return '<OptionalAttr:%s>' % self.attr_name - - def __call__(self): - return self - - -# alias -OAttr = OptionalAttr - - class Optional(object): """ Defines an optional parameter:: @@ -516,9 +492,6 @@ """ returns value from this Optional instance """ - if isinstance(self.type_, OAttr): - # use params name - return self.type_.attr_name return self.type_ @classmethod
--- a/kallithea/tests/api/api_base.py Fri Oct 09 19:43:18 2020 +0200 +++ b/kallithea/tests/api/api_base.py Fri Oct 09 19:45:13 2020 +0200 @@ -145,19 +145,6 @@ assert 1 == Optional.extract(Optional(1)) assert 'trololo' == Optional.extract('trololo') - def test_Optional_OAttr(self): - from kallithea.controllers.api.api import OAttr, Optional - - option1 = Optional(OAttr('apiuser')) - assert 'apiuser' == Optional.extract(option1) - - def test_OAttr_object(self): - from kallithea.controllers.api.api import OAttr - - oattr1 = OAttr('apiuser') - assert '<OptionalAttr:apiuser>' == repr(oattr1) - assert oattr1() == oattr1 - def test_api_wrong_key(self): id_, params = _build_data('trololo', 'get_user') response = api_call(self, params)