mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-08-21 06:33:17 +00:00
3.7.0
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user