Unittests passing for attributehandler updates.
This commit is contained in:
parent
e0268d6cb3
commit
c77252ebcb
2 changed files with 7 additions and 53 deletions
|
|
@ -159,7 +159,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
||||||
string = ""
|
string = ""
|
||||||
for nicktype in nicktypes:
|
for nicktype in nicktypes:
|
||||||
oldnick = caller.nicks.get(key=nickstring, category=nicktype, return_obj=True)
|
oldnick = caller.nicks.get(key=nickstring, category=nicktype, return_obj=True)
|
||||||
oldnick = oldnick if oldnick.key is not None else None
|
oldnick = oldnick.key if oldnick is not None else None
|
||||||
if oldnick:
|
if oldnick:
|
||||||
_, _, old_nickstring, old_replstring = oldnick.value
|
_, _, old_nickstring, old_replstring = oldnick.value
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -345,14 +345,6 @@ class AttributeHandler(object):
|
||||||
ret.extend(bool(attr) for attr in self._getcache(keystr, category))
|
ret.extend(bool(attr) for attr in self._getcache(keystr, category))
|
||||||
return ret[0] if len(ret) == 1 else ret
|
return ret[0] if len(ret) == 1 else ret
|
||||||
|
|
||||||
#if self._cache is None or not _TYPECLASS_AGGRESSIVE_CACHE:
|
|
||||||
# self._recache()
|
|
||||||
#key = [k.strip().lower() for k in make_iter(key) if k]
|
|
||||||
#category = category.strip().lower() if category is not None else None
|
|
||||||
#searchkeys = ["%s-%s" % (k, category) for k in make_iter(key)]
|
|
||||||
#ret = [self._cache.get(skey) for skey in searchkeys if skey in self._cache]
|
|
||||||
#return ret[0] if len(ret) == 1 else ret
|
|
||||||
|
|
||||||
def get(self, key=None, default=None, category=None, return_obj=False,
|
def get(self, key=None, default=None, category=None, return_obj=False,
|
||||||
strattr=False, raise_exception=False, accessing_obj=None,
|
strattr=False, raise_exception=False, accessing_obj=None,
|
||||||
default_access=True):
|
default_access=True):
|
||||||
|
|
@ -380,8 +372,10 @@ class AttributeHandler(object):
|
||||||
looked-after Attribute.
|
looked-after Attribute.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
result (any, Attribute or list): A list of varying type depending
|
result (any, Attribute or list): This will be the value of the found
|
||||||
on the arguments given.
|
Attribute unless `return_obj` is True, at which point it will be
|
||||||
|
the attribute object or None. If multiple keys are given, this
|
||||||
|
will be a list of values or attribute objects/None.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
AttributeError: If `raise_exception` is set and no matching Attribute
|
AttributeError: If `raise_exception` is set and no matching Attribute
|
||||||
|
|
@ -404,29 +398,11 @@ class AttributeHandler(object):
|
||||||
ret.extend(attr_objs)
|
ret.extend(attr_objs)
|
||||||
elif raise_exception:
|
elif raise_exception:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
|
elif return_obj:
|
||||||
|
ret.append(None)
|
||||||
else:
|
else:
|
||||||
ret.append(RetDefault())
|
ret.append(RetDefault())
|
||||||
|
|
||||||
# if self._cache is None or not _TYPECLASS_AGGRESSIVE_CACHE:
|
|
||||||
# self._recache()
|
|
||||||
# ret = []
|
|
||||||
# key = [k.strip().lower() for k in make_iter(key) if k]
|
|
||||||
# category = category.strip().lower() if category is not None else None
|
|
||||||
# if not key:
|
|
||||||
# # return all with matching category (or no category)
|
|
||||||
# catkey = "-%s" % category if category is not None else None
|
|
||||||
# ret = [attr for key, attr in self._cache.items() if key and key.endswith(catkey)]
|
|
||||||
# else:
|
|
||||||
# for searchkey in ("%s-%s" % (k, category) for k in key):
|
|
||||||
# attr_obj = self._cache.get(searchkey)
|
|
||||||
# if attr_obj:
|
|
||||||
# ret.append(attr_obj)
|
|
||||||
# else:
|
|
||||||
# if raise_exception:
|
|
||||||
# raise AttributeError
|
|
||||||
# else:
|
|
||||||
# ret.append(RetDefault())
|
|
||||||
|
|
||||||
if accessing_obj:
|
if accessing_obj:
|
||||||
# check 'attrread' locks
|
# check 'attrread' locks
|
||||||
ret = [attr for attr in ret if attr.access(accessing_obj, self._attrread, default=default_access)]
|
ret = [attr for attr in ret if attr.access(accessing_obj, self._attrread, default=default_access)]
|
||||||
|
|
@ -470,12 +446,6 @@ class AttributeHandler(object):
|
||||||
if not key:
|
if not key:
|
||||||
return
|
return
|
||||||
|
|
||||||
#
|
|
||||||
# if self._cache is None:
|
|
||||||
# self._recache()
|
|
||||||
# if not key:
|
|
||||||
# return
|
|
||||||
|
|
||||||
category = category.strip().lower() if category is not None else None
|
category = category.strip().lower() if category is not None else None
|
||||||
keystr = key.strip().lower()
|
keystr = key.strip().lower()
|
||||||
attr_obj = self._getcache(key, category)
|
attr_obj = self._getcache(key, category)
|
||||||
|
|
@ -536,12 +506,6 @@ class AttributeHandler(object):
|
||||||
# check create access
|
# check create access
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
#if self._cache is None:
|
|
||||||
# self._recache()
|
|
||||||
#if not key:
|
|
||||||
# return
|
|
||||||
|
|
||||||
keys, values = make_iter(key), make_iter(value)
|
keys, values = make_iter(key), make_iter(value)
|
||||||
|
|
||||||
if len(keys) != len(values):
|
if len(keys) != len(values):
|
||||||
|
|
@ -552,8 +516,6 @@ class AttributeHandler(object):
|
||||||
keystr = keystr.strip().lower()
|
keystr = keystr.strip().lower()
|
||||||
new_value = values[ikey]
|
new_value = values[ikey]
|
||||||
|
|
||||||
#cachekey = "%s-%s" % (keystr, category)
|
|
||||||
#attr_obj = self._cache.get(cachekey)
|
|
||||||
attr_objs = self._getcache(keystr, category)
|
attr_objs = self._getcache(keystr, category)
|
||||||
|
|
||||||
if attr_objs:
|
if attr_objs:
|
||||||
|
|
@ -605,11 +567,6 @@ class AttributeHandler(object):
|
||||||
was found matching `key`.
|
was found matching `key`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#if self._cache is None or not _TYPECLASS_AGGRESSIVE_CACHE:
|
|
||||||
# self._recache()
|
|
||||||
|
|
||||||
#key = [k.strip().lower() for k in make_iter(key) if k]
|
|
||||||
#category = category.strip().lower() if category is not None else None
|
|
||||||
for keystr in make_iter(key):
|
for keystr in make_iter(key):
|
||||||
attr_objs = self._getcache(keystr, category)
|
attr_objs = self._getcache(keystr, category)
|
||||||
for attr_obj in attr_objs:
|
for attr_obj in attr_objs:
|
||||||
|
|
@ -619,7 +576,6 @@ class AttributeHandler(object):
|
||||||
self._delcache(key, category)
|
self._delcache(key, category)
|
||||||
if not attr_objs and raise_exception:
|
if not attr_objs and raise_exception:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
#self._recache()
|
|
||||||
|
|
||||||
def clear(self, category=None, accessing_obj=None, default_access=True):
|
def clear(self, category=None, accessing_obj=None, default_access=True):
|
||||||
"""
|
"""
|
||||||
|
|
@ -635,8 +591,6 @@ class AttributeHandler(object):
|
||||||
type `attredit` on the Attribute in question.
|
type `attredit` on the Attribute in question.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#if self._cache is None or not _TYPECLASS_AGGRESSIVE_CACHE:
|
|
||||||
# self._recache()
|
|
||||||
if accessing_obj:
|
if accessing_obj:
|
||||||
[attr.delete() for attr in self._cache.values()
|
[attr.delete() for attr in self._cache.values()
|
||||||
if attr.access(accessing_obj, self._attredit, default=default_access)]
|
if attr.access(accessing_obj, self._attredit, default=default_access)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue