diff --git a/flask_soc_site/src/host_lookup.py b/flask_soc_site/src/host_lookup.py index a7f940c..2655fe7 100644 --- a/flask_soc_site/src/host_lookup.py +++ b/flask_soc_site/src/host_lookup.py @@ -32,7 +32,17 @@ class Lookedup(object): self.host_type = determine(self.host) self = self.specific() # TODO: consolidate all below functions if possible - # Implement an __eq__ method based on host name: https://dnmtechs.com/comparing-object-instances-by-attributes-in-python-3-a-comprehensive-guide/ + # DOING: Implement an __eq__ method based on host name: https://dnmtechs.com/comparing-object-instances-by-attributes-in-python-3-a-comprehensive-guide/ + + # From: https://stackoverflow.com/questions/14721062/python-comparing-2-lists-of-instances + def __hash__(self): + return hash((self.host, self.host_type)) + + def __eq__(self, other): + try: + return(self.host, self.host_type) == (other.host, other.host_type) + except AttributeError: + return NotImplemented def url_lookup(self): self.domain = urlparse(self.host).netloc @@ -149,7 +159,7 @@ def extract(user_input): # FIX: This function doesn't work for IP addresses, no usable whois() results def domain_info(host): result = dict(whois(host)) - print("RESULT IS: ", result) + # print("RESULT IS: ", result) if result["domain_name"] is not None: if type(result["creation_date"]) is list: result["creation_date"] = result["creation_date"][0].strftime("%d-%m-%Y")