Refactor code for readability and compatibility.

This commit is contained in:
Griatch 2017-01-27 00:19:27 +01:00
parent a09835049b
commit c6d9c0619e
43 changed files with 129 additions and 112 deletions

View file

@ -409,6 +409,7 @@ class ObjectDBManager(TypedObjectManager):
try:
matches = [matches[match_number]]
except IndexError:
# match number not matching anything
pass
# return a list (possibly empty)
return matches

View file

@ -242,12 +242,14 @@ class ObjectDB(TypedObject):
return
elif loc == self:
raise RuntimeError
elif loc == None:
elif loc is None:
raise RuntimeWarning
return is_loc_loop(loc.db_location, depth + 1)
try:
is_loc_loop(location)
except RuntimeWarning:
# we caught a infitite location loop!
# (location1 is in location2 which is in location1 ...)
pass
# if we get to this point we are ready to change location

View file

@ -83,7 +83,7 @@ class ObjectSessionHandler(object):
if sessid:
sessions = [_SESSIONS[sessid] if sessid in _SESSIONS else None] if sessid in self._sessid_cache else []
else:
sessions = [_SESSIONS[sessid] if sessid in _SESSIONS else None for sessid in self._sessid_cache]
sessions = [_SESSIONS[ssid] if ssid in _SESSIONS else None for ssid in self._sessid_cache]
if None in sessions:
# this happens only if our cache has gone out of sync with the SessionHandler.
self._recache()