This commit is contained in:
Sean Whalen
2018-07-18 09:46:40 -04:00
parent de0a3b7c56
commit b97a6f5150
3 changed files with 18 additions and 11 deletions
+6
View File
@@ -1,3 +1,9 @@
3.7.0
-----
- Fix bug where PSL would be called before it was downloaded if the PSL was
older than 24 Hours
3.6.1
-----
+11 -10
View File
@@ -43,7 +43,7 @@ import imapclient.exceptions
import dateparser
import mailparser
__version__ = "3.6.1"
__version__ = "3.7.0"
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
@@ -100,22 +100,23 @@ def _get_base_domain(domain):
psl_path = ".public_suffix_list.dat"
def download_psl():
fresh_psl = publicsuffix.fetch()
fresh_psl = publicsuffix.fetch().read()
with open(psl_path, "w", encoding="utf-8") as fresh_psl_file:
fresh_psl_file.write(fresh_psl.read())
return publicsuffix.PublicSuffixList(fresh_psl)
fresh_psl_file.write(fresh_psl)
if not os.path.exists(psl_path):
psl = download_psl()
download_psl()
else:
psl_age = datetime.now() - datetime.fromtimestamp(
os.stat(psl_path).st_mtime)
if psl_age > timedelta(hours=24):
psl = download_psl()
else:
with open(psl_path, encoding="utf-8") as psl_file:
psl = publicsuffix.PublicSuffixList(psl_file)
try:
download_psl()
except Exception as error:
logger.warning("Failed to download an updated PSL - \
{0}".format(error))
with open(psl_path, encoding="utf-8") as psl_file:
psl = publicsuffix.PublicSuffixList(psl_file)
return psl.get_public_suffix(domain)
+1 -1
View File
@@ -14,7 +14,7 @@ from setuptools import setup
from codecs import open
from os import path
__version__ = "3.6.1"
__version__ = "3.7.0"
description = "A Python package and CLI for parsing aggregate and " \
"forensic DMARC reports"