Created
September 12, 2016 19:40
-
-
Save mrjoes/ea2c6e8a57d4a0b646c26c7d545b3674 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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