Fix two PEP8 errors

This commit is contained in:
JoeLametta
2018-01-04 20:57:24 +01:00
parent 1247c94e8c
commit 75a3d4bce1
2 changed files with 8 additions and 10 deletions

View File

@@ -16,7 +16,8 @@ soup = BeautifulSoup.BeautifulSoup(doc)
offsets = {} # offset -> total count
rows = soup.findAll('tr')
# skip first two spurious elements
rows = soup.findAll('tr')[2:]
for row in rows:
columns = row.findAll('td')
if len(columns) == 4:
@@ -25,20 +26,15 @@ for row in rows:
offset = second.find(text=True)
count = third.find(text=True)
# only use sensible offsets
# only use numeric offsets
try:
int(offset)
except:
except ValueError:
continue
if offset not in offsets.keys():
offsets[offset] = 0
# first line is text, so int will fail with ValueError
# purged entries will have None as count, so TypeError
try:
offsets[offset] += int(count)
except (ValueError, TypeError):
pass
offsets[offset] += int(count)
# now sort offsets by count
counts = []

View File

@@ -104,9 +104,11 @@ class Persister:
try:
self.object = pickle.load(handle)
logger.debug('loaded persisted object from %r' % self._path)
except:
except Exception as e:
# TODO: restrict kind of caught exceptions?
# can fail for various reasons; in that case, pretend we didn't
# load it
logger.debug(e)
pass
def delete(self):