def set_difficulty_limit(self, limit): if not cross_version.isinteger(limit): raise ValueError("Difficulty limit must be integer format") if limit == 0: self.__difficulty = None else: self.__difficulty = limit
def set_difficulty(self, difficulty): if cross_version.isinteger(difficulty): if difficulty >= 1 and difficulty <= 3: self.__difficulty = difficulty else: raise ValueError("Invalid difficulty number ( Must be 1 - 3 )") return elif cross_version.isstring(difficulty): self.__difficulty = convert_difficulty(difficulty) else: raise ValueError("Invalid type for difficulty")
def has_difficulty(self, search): if cross_version.isstring(search): search = convert_difficulty(search) if not cross_version.isinteger(search): raise ValueError("Invalid difficulty") for vuln in self.__vulnerability_list: if self.__vulnerability_list[vuln].get_difficulty() <= search or self.__vulnerability_list[vuln].get_difficulty() == None: return True return False
def has_difficulty(self, search): if cross_version.isstring(search): search = convert_difficulty(search) if not cross_version.isinteger(search): raise ValueError("Invalid difficulty") for vuln in self.__vulnerability_list: if ( self.__vulnerability_list[vuln].get_difficulty() <= search or self.__vulnerability_list[vuln].get_difficulty() == None ): return True return False
def isinteger_tests(): assert cross_version.isinteger("hi there") == False assert cross_version.isinteger(1) == True assert cross_version.isinteger(1.01) == False assert cross_version.isinteger({1: 2}) == False