def getranking(self, cpeid=None, loosy=True): if cpeid is None: return False result = False i = None if loosy: for x in cpeid.split(":"): if x != "": i = findRanking(x, regex=True) if i is None: continue if "rank" in i: result = i["rank"] else: i = findRanking(cpeid, regex=True) if i is None: return result if "rank" in i: result = i["rank"] return result
def listranking(format="json"): ranks = [] for x in findRanking(): if format == "json": ranks.append(x) else: ranks.append(x["cpe"] + " " + str(x["rank"])) return ranks
def findranking(cpe=None, loosy=True): if cpe is None: return False result = False i = None if loosy: for x in cpe.split(":"): if x != "": i = findRanking(x, regex=True) if i is None: continue if "rank" in i: result = i["rank"] else: i = findRanking(cpe, regex=True) print(cpe) if i is None: return result if "rank" in i: result = i["rank"] return result