Some minor style fixes.
This commit is contained in:
parent
b8484cde50
commit
8b90aa5cfb
18 changed files with 71 additions and 40 deletions
|
@ -15,8 +15,6 @@ Comic modules for each comic are located in L{dosagelib.plugins}.
|
|||
"""
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pbr.version import VersionInfo
|
||||
|
||||
AppName = u'dosage'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
@ -22,6 +22,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
|||
with out.pager():
|
||||
out.info(self.format_help())
|
||||
|
||||
|
||||
Examples = """\
|
||||
EXAMPLES
|
||||
List available comics:
|
||||
|
@ -293,6 +294,7 @@ def do_column_list(scrapers):
|
|||
del names[:names_per_line]
|
||||
return num, disabled
|
||||
|
||||
|
||||
TAG_ADULT = "adult"
|
||||
TAG_LANG = "lang"
|
||||
TAG_DISABLED = "dis"
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
"""
|
||||
Define basic configuration data like version or application name.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from . import AppName, AppVersion
|
||||
|
||||
App = AppName + u' ' + AppVersion
|
||||
|
@ -18,7 +19,7 @@ UserAgent = u"Mozilla/5.0 (compatible; %s/%s; +%s)" % (AppName, AppVersion,
|
|||
Url)
|
||||
Copyright = u"""Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
"""
|
||||
Freeware = AppName + u""" comes with ABSOLUTELY NO WARRANTY!
|
||||
This is free software, and you are welcome to redistribute it
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
@ -310,6 +310,7 @@ def addHandlerClass(clazz):
|
|||
raise ValueError("%s must be subclassed from %s" % (clazz, EventHandler))
|
||||
_handler_classes[clazz.name] = clazz
|
||||
|
||||
|
||||
addHandlerClass(HtmlEventHandler)
|
||||
addHandlerClass(RSSEventHandler)
|
||||
addHandlerClass(JSONEventHandler)
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# ISO 693-1 language codes from pycountry
|
||||
# This file is automatically generated, DO NOT EDIT!
|
||||
from __future__ import absolute_import, division, print_function
|
||||
Languages = {
|
||||
'de': u'German',
|
||||
'en': u'English',
|
||||
'es': u'Spanish; Castilian',
|
||||
'fi': u'Finnish',
|
||||
'fr': u'French',
|
||||
'it': u'Italian',
|
||||
'ja': u'Japanese',
|
||||
'pt': u'Portuguese',
|
||||
'de': 'German',
|
||||
'en': 'English',
|
||||
'es': 'Spanish; Castilian',
|
||||
'fi': 'Finnish',
|
||||
'fr': 'French',
|
||||
'it': 'Italian',
|
||||
'ja': 'Japanese',
|
||||
'pt': 'Portuguese',
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from re import compile, escape
|
||||
from ..scraper import _BasicScraper
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from ..scraper import _ParserScraper
|
||||
from ..helpers import bounceStarter
|
||||
|
||||
|
||||
class Xkcd(_ParserScraper):
|
||||
name = 'xkcd'
|
||||
url = 'http://xkcd.com/'
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# TODO: Not sure if this RSS output is "valid", should be though.
|
||||
# Might also be nice categorise Comics under one Item
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import xml.dom.minidom
|
||||
import time
|
||||
from .configuration import App
|
||||
|
||||
# TODO: Not sure if this RSS output is "valid", should be though.
|
||||
# Might also be nice categorise Comics under one Item
|
||||
|
||||
|
||||
class Feed(object):
|
||||
"""Write an RSS feed with comic strip images."""
|
||||
|
||||
|
@ -62,8 +67,11 @@ def parseFeed(filename, yesterday):
|
|||
"""Parse an RSS feed and filter only entries that are newer than yesterday."""
|
||||
dom = xml.dom.minidom.parse(filename)
|
||||
|
||||
getText = lambda node, tag: node.getElementsByTagName(tag)[0].childNodes[0].data
|
||||
getNode = lambda tag: dom.getElementsByTagName(tag)
|
||||
def getText(node, tag):
|
||||
node.getElementsByTagName(tag)[0].childNodes[0].data
|
||||
|
||||
def getNode(tag):
|
||||
dom.getElementsByTagName(tag)
|
||||
|
||||
content = getNode('channel')[0] # Only one channel node
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copied from: https://github.com/pycontribs/tendo
|
||||
# License: PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
||||
# Author: Sorin Sbarnea
|
||||
# Changes: changed logging and formatting
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import sys
|
||||
import os
|
||||
import errno
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
"""
|
||||
Function to check for updates.
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import os
|
||||
import dosagelib
|
||||
from dosagelib import configuration
|
||||
|
@ -9,10 +12,10 @@ from .util import urlopen
|
|||
from distutils.version import StrictVersion
|
||||
import requests
|
||||
|
||||
|
||||
UPDATE_URL = "https://api.github.com/repos/webcomics/dosage/releases/latest"
|
||||
|
||||
def check_update ():
|
||||
|
||||
def check_update():
|
||||
"""Return the following values:
|
||||
(False, errmsg) - online version could not be determined
|
||||
(True, None) - user has newest version
|
||||
|
@ -33,7 +36,7 @@ def check_update ():
|
|||
return True, (version, None)
|
||||
|
||||
|
||||
def get_online_version ():
|
||||
def get_online_version():
|
||||
"""Download update info and parse it."""
|
||||
session = requests.session()
|
||||
page = urlopen(UPDATE_URL, session).json()
|
||||
|
@ -47,6 +50,6 @@ def get_online_version ():
|
|||
return version, url
|
||||
|
||||
|
||||
def is_newer_version (version):
|
||||
def is_newer_version(version):
|
||||
"""Check if given version is newer than current version."""
|
||||
return StrictVersion(version) > StrictVersion(dosagelib.__version__)
|
||||
|
|
|
@ -40,5 +40,6 @@ class CreatorsUpdater(ComicListUpdater):
|
|||
langopt = ", 'es'" if name.lower().endswith('spanish') else ''
|
||||
return u"cls('%s', '%s'%s)," % (name, path, langopt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
CreatorsUpdater(__file__).run()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
'''update languages.py from pycountry'''
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
@ -24,6 +24,7 @@ def main():
|
|||
f.write('# -*- coding: %s -*-%s' % (encoding, os.linesep))
|
||||
f.write('# ISO 693-1 language codes from pycountry%s' % os.linesep)
|
||||
f.write('# This file is automatically generated, DO NOT EDIT!%s' % os.linesep)
|
||||
f.write('from __future__ import absolute_import, division, print_function%s' % os.linesep)
|
||||
lang = get_used_languages()
|
||||
write_languages(f, lang)
|
||||
|
||||
|
|
|
@ -167,5 +167,6 @@ class SmackJeevesUpdater(ComicListUpdater):
|
|||
opt += ", endOfLife=True"
|
||||
return u"cls('%s', %s)," % (name, opt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
SmackJeevesUpdater(__file__).run()
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2013-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# Copyright (C) 2013-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2015-2016 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import pytest
|
||||
from dosagelib import scraper
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# Author: Sorin Sbarnea
|
||||
# Changes: changed logging and formatting
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
from dosagelib import singleton
|
||||
from multiprocessing import Process
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
|
||||
# Copyright (C) 2012-2014 Bastian Kleineidam
|
||||
# Copyright (C) 2016 Tobias Gruetzmacher
|
||||
# Copyright (C) 2015-2017 Tobias Gruetzmacher
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import pytest
|
||||
import re
|
||||
|
@ -30,9 +32,9 @@ class TestRegex(object):
|
|||
ValuePrefix = '/bla/'
|
||||
|
||||
@pytest.mark.parametrize("tag,value,domatch", [
|
||||
('<img src="%s">', ValuePrefix+'foo', True),
|
||||
('<img src="%s">', ValuePrefix + 'foo', True),
|
||||
('< img src = "%s" >', ValuePrefix, True),
|
||||
('<img class="prev" src="%s">', ValuePrefix+'...', True),
|
||||
('<img class="prev" src="%s">', ValuePrefix + '...', True),
|
||||
('<img origsrc="%s">', ValuePrefix, False),
|
||||
('<Img src="%s">', ValuePrefix, True),
|
||||
('<img SrC="%s">', ValuePrefix, True),
|
||||
|
|
Loading…
Reference in a new issue