whois/parser.py
changeset 121 ccd653a54263
parent 120 b4273400685e
child 123 03c72d0d1182
equal deleted inserted replaced
120:b4273400685e 121:ccd653a54263
   123         The attribute is then set to be accessed directly by subsequent calls.
   123         The attribute is then set to be accessed directly by subsequent calls.
   124         """
   124         """
   125         for attr, regex in list(self._regex.items()):
   125         for attr, regex in list(self._regex.items()):
   126             if regex:
   126             if regex:
   127                 values = []
   127                 values = []
   128                 for value in re.findall(regex, self.text, re.IGNORECASE):
   128                 for data in re.findall(regex, self.text, re.IGNORECASE):
   129                     value = value.strip()
   129                     matches = data if isinstance(data, tuple) else [data]
   130                     if value and isinstance(value, basestring) and not value.isdigit() and '_date' in attr:
   130                     for value in matches:
   131                         # try casting to date format
   131                         value = value.strip()
   132                         value = cast_date(
   132                         if value and isinstance(value, basestring) and not value.isdigit() and '_date' in attr:
   133                             value,
   133                             # try casting to date format
   134                             dayfirst=self.dayfirst,
   134                             value = cast_date(
   135                             yearfirst=self.yearfirst)
   135                                 value,
   136                     if value and value not in values:
   136                                 dayfirst=self.dayfirst,
   137                         # avoid duplicates
   137                                 yearfirst=self.yearfirst)
   138                         values.append(value)
   138                         if value and value not in values:
       
   139                             # avoid duplicates
       
   140                             values.append(value)
   139                 if values and attr in ('registrar', 'whois_server', 'referral_url'):
   141                 if values and attr in ('registrar', 'whois_server', 'referral_url'):
   140                     values = values[-1] # ignore junk
   142                     values = values[-1] # ignore junk
   141                 if len(values) == 1:
   143                 if len(values) == 1:
   142                     values = values[0]
   144                     values = values[0]
   143                 elif not values:
   145                 elif not values: