diff --git a/.flake8 b/.flake8 index b54fd1e..2215651 100644 --- a/.flake8 +++ b/.flake8 @@ -4,4 +4,6 @@ ignore = # E128, # E501 line too long E501 + # W504 line break after binary operator + W504 exclude = .git,__pycache__,venv diff --git a/leech.py b/leech.py index e068fa5..d3688f0 100755 --- a/leech.py +++ b/leech.py @@ -41,7 +41,9 @@ def create_session(cache): lwp_cookiejar = http.cookiejar.LWPCookieJar() try: lwp_cookiejar.load('leech.cookies', ignore_discard=True) - except Exception as e: + except Exception: + # This file is very much optional, so this log isn't really necessary + # logging.exception("Couldn't load cookies from leech.cookies") pass session.cookies = lwp_cookiejar session.headers.update({ diff --git a/sites/ao3.py b/sites/ao3.py index ec9f06f..17f1cd3 100644 --- a/sites/ao3.py +++ b/sites/ao3.py @@ -72,9 +72,11 @@ class ArchiveOfOurOwn(Site): "(%Y-%m-%d)" ) - contents = self._chapter(soup.find(id='chapter-{}'.format(index+1))) - - story.add(Chapter(title=link.string, contents=contents, date=updated)) + story.add(Chapter( + title=link.string, + contents=self._chapter(soup.find(id='chapter-{}'.format(index + 1))), + date=updated + )) return story diff --git a/sites/deviantart.py b/sites/deviantart.py index df30e92..0baec17 100644 --- a/sites/deviantart.py +++ b/sites/deviantart.py @@ -41,9 +41,9 @@ class DeviantArt(Stash): return for thumb in thumbs: try: - if thumb['href'] is not '#': + if thumb['href'] != '#': story.add(self._chapter(thumb['href'])) - except Exception as e: + except Exception: logger.exception("Couldn't extract chapters from thumbs") return story diff --git a/sites/fanfictionnet.py b/sites/fanfictionnet.py index 7f86aed..32f9172 100644 --- a/sites/fanfictionnet.py +++ b/sites/fanfictionnet.py @@ -76,7 +76,7 @@ class FanFictionNet(Site): try: for tag in text.find_all(True): tag.attrs = None - except Exception as e: + except Exception: logger.exception("Trouble cleaning attributes") return text.prettify() diff --git a/sites/royalroad.py b/sites/royalroad.py index c40fe57..73f4d52 100644 --- a/sites/royalroad.py +++ b/sites/royalroad.py @@ -55,13 +55,13 @@ class RoyalRoad(Site): author_note = soup.find_all('div', class_='author-note-portlet') - if len(author_note) is 1: + if len(author_note) == 1: # Find the parent of chapter-content and check if the author's note is the first child div if 'author-note-portlet' in soup.find('div', class_='chapter-content').parent.find('div')['class']: content = author_note[0].prettify() + '
' + content else: # The author note must be after the chapter content content = content + '
' + author_note[0].prettify() - elif len(author_note) is 2: + elif len(author_note) == 2: content = author_note[0].prettify() + '
' + content + '
' + author_note[1].prettify() updated = datetime.datetime.fromtimestamp( diff --git a/sites/stash.py b/sites/stash.py index 9c77b83..952b08b 100644 --- a/sites/stash.py +++ b/sites/stash.py @@ -35,9 +35,9 @@ class Stash(Site): return for thumb in thumbs: try: - if thumb['href'] is not '#': + if thumb['href'] != '#': story.add(self._chapter(thumb['href'])) - except Exception as e: + except Exception: logger.exception("Couldn't extract chapters from thumbs") return story