Commits

Peter Nixon committed 1a4cad3

Init tldextract only one so that it is faster and tell it not to try and update its data file

  • Participants
  • Parent commits c05f603

Comments (0)

Files changed (2)

     from optparse import OptionParser
 
     parser = OptionParser(usage='usage: %prog [options] filename')
+
+    parser.add_option("-c", "--code", dest="code", default=None, type="int",
+                      help='Filter output on HTTP Status code (default: None)')
                       
     parser.add_option('-r', '--refresh', dest='refresh', default=5, type='int',
                       help='screen refresh interval')

File bmutils/bmutils.py

 __license__ = "Public Domain"
 __version__ = "1.1"
 
+import os
 import re
 import time
 import logging
 
 DEBUG = False
 
+TLD_CACHE = os.path.join(os.path.dirname(__file__), 'effective_tld_names.dat')
+
 logging.basicConfig()
 _pattern = re.compile(
         ### Beware, all ye who enter, for here be dragons! ###
         self.timestamp = ''
         self.url = ''
         self.utime = 0
+        self.tldextract = tldextract.TLDExtract(fetch=False)
 
     def gethostname(self):
         '''
             self.domainname = self.httphost
             return None
         else:
-            no_fetch_extract = tldextract.TLDExtract(fetch=False)
-            ext = tldextract.extract(self.url)      # Extract TLD parts
+            ext = self.tldextract(self.url)    # Extract TLD parts
             if ext.tld == '':
                 # There is no TLD so just return domain (Most likely an IP address)
                 return ext.domain