mirror of
https://github.com/kemayo/leech
synced 2025-12-06 16:33:16 +01:00
Fix flake8 errors
This commit is contained in:
parent
e8f9c6a085
commit
66576048da
7 changed files with 17 additions and 11 deletions
2
.flake8
2
.flake8
|
|
@ -4,4 +4,6 @@ ignore =
|
|||
# E128,
|
||||
# E501 line too long
|
||||
E501
|
||||
# W504 line break after binary operator
|
||||
W504
|
||||
exclude = .git,__pycache__,venv
|
||||
|
|
|
|||
4
leech.py
4
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({
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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() + '<hr/>' + content
|
||||
else: # The author note must be after the chapter content
|
||||
content = content + '<hr/>' + author_note[0].prettify()
|
||||
elif len(author_note) is 2:
|
||||
elif len(author_note) == 2:
|
||||
content = author_note[0].prettify() + '<hr/>' + content + '<hr/>' + author_note[1].prettify()
|
||||
|
||||
updated = datetime.datetime.fromtimestamp(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue