summaryrefslogtreecommitdiff
path: root/pelican/cache.py
diff options
context:
space:
mode:
authorJustin Mayer <entroP@gmail.com>2020-04-26 09:55:08 +0200
committerJustin Mayer <entroP@gmail.com>2020-04-27 09:45:31 +0200
commitd43b786b300358e8a4cbae4afc4052199a7af762 (patch)
tree8c2231297301b1eb307e3c132ca4710cacd5eef0 /pelican/cache.py
parent2cd1d44576ecc4fd0cc532cbb19c2b934ab5c665 (diff)
downloadpelican-remove-legacy.tar.gz
Modernize code base to Python 3+ syntaxremove-legacy
Replaces syntax that was relevant in earlier Python versions but that now has modernized equivalents.
Diffstat (limited to 'pelican/cache.py')
-rw-r--r--pelican/cache.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/pelican/cache.py b/pelican/cache.py
index 7d6ee992..646f97bc 100644
--- a/pelican/cache.py
+++ b/pelican/cache.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import hashlib
import logging
import os
@@ -10,7 +8,7 @@ from pelican.utils import mkdir_p
logger = logging.getLogger(__name__)
-class FileDataCacher(object):
+class FileDataCacher:
"""Class that can cache data contained in files"""
def __init__(self, settings, cache_name, caching_policy, load_policy):
@@ -33,7 +31,7 @@ class FileDataCacher(object):
try:
with self._cache_open(self._cache_path, 'rb') as fhandle:
self._cache = pickle.load(fhandle)
- except (IOError, OSError, UnicodeDecodeError) as err:
+ except (OSError, UnicodeDecodeError) as err:
logger.debug('Cannot load cache %s (this is normal on first '
'run). Proceeding with empty cache.\n%s',
self._cache_path, err)
@@ -67,7 +65,7 @@ class FileDataCacher(object):
mkdir_p(self.settings['CACHE_PATH'])
with self._cache_open(self._cache_path, 'wb') as fhandle:
pickle.dump(self._cache, fhandle)
- except (IOError, OSError, pickle.PicklingError) as err:
+ except (OSError, pickle.PicklingError) as err:
logger.warning('Could not save cache %s\n ... %s',
self._cache_path, err)
@@ -116,7 +114,7 @@ class FileStampDataCacher(FileDataCacher):
try:
return self._filestamp_func(filename)
- except (IOError, OSError, TypeError) as err:
+ except (OSError, TypeError) as err:
logger.warning('Cannot get modification stamp for %s\n\t%s',
filename, err)
return ''