Skip to content

Instantly share code, notes, and snippets.

@mrjoes
Created September 12, 2016 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjoes/ea2c6e8a57d4a0b646c26c7d545b3674 to your computer and use it in GitHub Desktop.
Save mrjoes/ea2c6e8a57d4a0b646c26c7d545b3674 to your computer and use it in GitHub Desktop.
def _pick_by_class_ref(self, cls_ref, comparision_type="exact"):
func = getattr(self, comparision_type)
try:
_refs = self.db["key"][cls_ref]
except KeyError:
return []
else:
_item = self.db["info"][_refs[0]]
_level = _item["level"]
if comparision_type != "better":
if _item["method"]:
res = [(_item["method"], _refs[0])]
else:
res = []
else:
res = []
for ref in _refs[1:]:
item = self.db["info"][ref]
res.append((item["method"], ref))
if func(_level, item["level"]):
_level = item["level"]
for ref, _dic in self.db["info"].items():
if ref in _refs:
continue
elif func(_level, _dic["level"]):
if _dic["method"]:
_val = (_dic["method"], ref)
if _val not in res:
res.append(_val)
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment