1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 16:33:16 +01:00

Fix flake8 errors

This commit is contained in:
David Lynch 2019-05-25 20:03:17 -05:00
parent e8f9c6a085
commit 66576048da
7 changed files with 17 additions and 11 deletions

View file

@ -4,4 +4,6 @@ ignore =
# E128, # E128,
# E501 line too long # E501 line too long
E501 E501
# W504 line break after binary operator
W504
exclude = .git,__pycache__,venv exclude = .git,__pycache__,venv

View file

@ -41,7 +41,9 @@ def create_session(cache):
lwp_cookiejar = http.cookiejar.LWPCookieJar() lwp_cookiejar = http.cookiejar.LWPCookieJar()
try: try:
lwp_cookiejar.load('leech.cookies', ignore_discard=True) 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 pass
session.cookies = lwp_cookiejar session.cookies = lwp_cookiejar
session.headers.update({ session.headers.update({

View file

@ -72,9 +72,11 @@ class ArchiveOfOurOwn(Site):
"(%Y-%m-%d)" "(%Y-%m-%d)"
) )
contents = self._chapter(soup.find(id='chapter-{}'.format(index+1))) story.add(Chapter(
title=link.string,
story.add(Chapter(title=link.string, contents=contents, date=updated)) contents=self._chapter(soup.find(id='chapter-{}'.format(index + 1))),
date=updated
))
return story return story

View file

@ -41,9 +41,9 @@ class DeviantArt(Stash):
return return
for thumb in thumbs: for thumb in thumbs:
try: try:
if thumb['href'] is not '#': if thumb['href'] != '#':
story.add(self._chapter(thumb['href'])) story.add(self._chapter(thumb['href']))
except Exception as e: except Exception:
logger.exception("Couldn't extract chapters from thumbs") logger.exception("Couldn't extract chapters from thumbs")
return story return story

View file

@ -76,7 +76,7 @@ class FanFictionNet(Site):
try: try:
for tag in text.find_all(True): for tag in text.find_all(True):
tag.attrs = None tag.attrs = None
except Exception as e: except Exception:
logger.exception("Trouble cleaning attributes") logger.exception("Trouble cleaning attributes")
return text.prettify() return text.prettify()

View file

@ -55,13 +55,13 @@ class RoyalRoad(Site):
author_note = soup.find_all('div', class_='author-note-portlet') 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 # 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']: if 'author-note-portlet' in soup.find('div', class_='chapter-content').parent.find('div')['class']:
content = author_note[0].prettify() + '<hr/>' + content content = author_note[0].prettify() + '<hr/>' + content
else: # The author note must be after the chapter content else: # The author note must be after the chapter content
content = content + '<hr/>' + author_note[0].prettify() 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() content = author_note[0].prettify() + '<hr/>' + content + '<hr/>' + author_note[1].prettify()
updated = datetime.datetime.fromtimestamp( updated = datetime.datetime.fromtimestamp(

View file

@ -35,9 +35,9 @@ class Stash(Site):
return return
for thumb in thumbs: for thumb in thumbs:
try: try:
if thumb['href'] is not '#': if thumb['href'] != '#':
story.add(self._chapter(thumb['href'])) story.add(self._chapter(thumb['href']))
except Exception as e: except Exception:
logger.exception("Couldn't extract chapters from thumbs") logger.exception("Couldn't extract chapters from thumbs")
return story return story