whois/parser.py
branchpython3
changeset 70 1fe2c20adeba
parent 64 2ed54e885571
child 71 b181f795cc0d
equal deleted inserted replaced
65:50b5966b5566 70:1fe2c20adeba
       
     1 from __future__ import absolute_import
       
     2 from __future__ import unicode_literals
       
     3 from __future__ import print_function
       
     4 from __future__ import division
       
     5 from future import standard_library
       
     6 standard_library.install_aliases()
       
     7 from builtins import *
       
     8 from builtins import str
       
     9 from past.builtins import basestring
     1 # coding=utf-8
    10 # coding=utf-8
     2 # parser.py - Module for parsing whois response data
    11 # parser.py - Module for parsing whois response data
     3 # Copyright (c) 2008 Andrey Petrov
    12 # Copyright (c) 2008 Andrey Petrov
     4 #
    13 #
     5 # This module is part of pywhois and is released under
    14 # This module is part of pywhois and is released under
     9 import json
    18 import json
    10 from datetime import datetime
    19 from datetime import datetime
    11 import re
    20 import re
    12 try:
    21 try:
    13     import dateutil.parser as dp
    22     import dateutil.parser as dp
    14     from time_zones import tz_data
    23     from .time_zones import tz_data
    15     DATEUTIL = True
    24     DATEUTIL = True
    16 except ImportError:
    25 except ImportError:
    17     DATEUTIL = False
    26     DATEUTIL = False
    18 
    27 
    19 KNOWN_FORMATS = [
    28 KNOWN_FORMATS = [
   108 
   117 
   109     def parse(self):
   118     def parse(self):
   110         """The first time an attribute is called it will be calculated here.
   119         """The first time an attribute is called it will be calculated here.
   111         The attribute is then set to be accessed directly by subsequent calls.
   120         The attribute is then set to be accessed directly by subsequent calls.
   112         """
   121         """
   113         for attr, regex in self._regex.items():
   122         for attr, regex in list(self._regex.items()):
   114             if regex:
   123             if regex:
   115                 values = []
   124                 values = []
   116                 for value in re.findall(regex, self.text, re.IGNORECASE):
   125                 for value in re.findall(regex, self.text, re.IGNORECASE):
   117                     if isinstance(value, basestring):
   126                     if isinstance(value, basestring):
   118                         # try casting to date format
   127                         # try casting to date format