From baee878692b87f18bdf9cd9eb080c131a10f495d Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 6 Sep 2015 18:34:19 +0200 Subject: [PATCH] Fix post-processing of empty but existent registrant entries, like for the.ai --- pythonwhois/parse.py | 4 +++ test/data/the.ai | 60 +++++++++++++++++++++++++++++++++++ test/target_default/the.ai | 1 + test/target_normalized/the.ai | 1 + 4 files changed, 66 insertions(+) create mode 100644 test/data/the.ai create mode 100644 test/target_default/the.ai create mode 100644 test/target_normalized/the.ai diff --git a/pythonwhois/parse.py b/pythonwhois/parse.py index e601c3f..af270f5 100644 --- a/pythonwhois/parse.py +++ b/pythonwhois/parse.py @@ -856,6 +856,10 @@ def normalize_data(data, normalized): if contact[key] == "-" or contact[key].lower() == "n/a" or contact[key].lower() == "null": del contact[key] + + if contact is not None and len(contact) == 0: + # We don't have any actual data. + data['contacts'][contact_type] = None return data def deduplicate(value, fuzzy=False): diff --git a/test/data/the.ai b/test/data/the.ai new file mode 100644 index 0000000..5718d20 --- /dev/null +++ b/test/data/the.ai @@ -0,0 +1,60 @@ +DOMAIN INFORMATION + + Complete Domain Name........: the.ai +Organization Using Domain Name + Organization Name..........: + Street Address.............: + City.......................: + State......................: + Postal Code................: + Country....................: +Administrative Contact + NIC Handle (if known)......: + (I)ndividual (R)ole........: + Name (Last, First).........: + Organization Name..........: + Street Address.............: + City.......................: + State......................: + Postal Code................: + Country....................: + Phone Number...............: + Fax Number.................: + E-Mailbox..................: ighmail@gmail.com +Technical Contact + NIC Handle (if known)......: + (I)ndividual (R)ole........: + Name (Last, First).........: + Organization Name..........: + Street Address.............: + City.......................: + State......................: + Postal Code................: + Country....................: + Phone Number...............: + Fax Number.................: + E-Mailbox..................: +Billing Contact + NIC Handle (if known)......: + (I)ndividual (R)ole........: + Name (Last, First).........: + Organization Name..........: + Street Address.............: + City.......................: + State......................: + Postal Code................: + Country....................: + Phone Number...............: + Fax Number.................: + E-Mailbox..................: +Nameservers + Primary Server Hostname....: ns51.1and1.com + Primary Server Netaddress..: + Secondary Server Hostname..: ns52.1and1.com + Secondary Server Netaddress: + Third Server Hostname......: + Fourth Server Hostname.....: + + +Last paid by: ighmail@gmail.com + diff --git a/test/target_default/the.ai b/test/target_default/the.ai new file mode 100644 index 0000000..ed65a2a --- /dev/null +++ b/test/target_default/the.ai @@ -0,0 +1 @@ +{"nameservers": ["ns51.1and1.com", "ns52.1and1.com"], "raw": ["DOMAIN INFORMATION\n\n Complete Domain Name........: the.ai\nOrganization Using Domain Name\n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \nAdministrative Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: ighmail@gmail.com\nTechnical Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: \nBilling Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: \nNameservers\n Primary Server Hostname....: ns51.1and1.com\n Primary Server Netaddress..: \n Secondary Server Hostname..: ns52.1and1.com\n Secondary Server Netaddress: \n Third Server Hostname......: \n Fourth Server Hostname.....: \n\n\nLast paid by: ighmail@gmail.com\n\n"], "contacts": {"admin": {"email": "ighmail@gmail.com"}, "tech": {}, "registrant": {}, "billing": {}}} \ No newline at end of file diff --git a/test/target_normalized/the.ai b/test/target_normalized/the.ai new file mode 100644 index 0000000..7a17f4a --- /dev/null +++ b/test/target_normalized/the.ai @@ -0,0 +1 @@ +{"nameservers": ["ns51.1and1.com", "ns52.1and1.com"], "raw": ["DOMAIN INFORMATION\n\n Complete Domain Name........: the.ai\nOrganization Using Domain Name\n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \nAdministrative Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: ighmail@gmail.com\nTechnical Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: \nBilling Contact\n NIC Handle (if known)......: \n (I)ndividual (R)ole........: \n Name (Last, First).........: \n Organization Name..........: \n Street Address.............: \n City.......................: \n State......................: \n Postal Code................: \n Country....................: \n Phone Number...............: \n Fax Number.................: \n E-Mailbox..................: \nNameservers\n Primary Server Hostname....: ns51.1and1.com\n Primary Server Netaddress..: \n Secondary Server Hostname..: ns52.1and1.com\n Secondary Server Netaddress: \n Third Server Hostname......: \n Fourth Server Hostname.....: \n\n\nLast paid by: ighmail@gmail.com\n\n"], "contacts": {"admin": {"email": "ighmail@gmail.com"}, "tech": null, "registrant": null, "billing": null}} \ No newline at end of file