pep8 blank lines fixes

flake8 --select W391,E302,E301,E304

autopep8 can't fix W391 even though it claims it can.
Fixed using a simple custom script.
This commit is contained in:
Laurent Bachelier 2014-10-10 23:04:08 +02:00
commit 448c06d125
142 changed files with 249 additions and 25 deletions

View file

@ -105,6 +105,7 @@ class OfxFormatter(IFormatter):
self.output(u'<DTASOF>%s</AVAILBAL>' % datetime.date.today().strftime('%Y%m%d'))
self.output(u'</STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>')
class QifFormatter(IFormatter):
MANDATORY_FIELDS = ('id', 'date', 'raw', 'amount')

View file

@ -58,6 +58,7 @@ class HistoryFormatter(IFormatter):
self.colored('%-17s' % (obj.location or ''), 'magenta'),
self.colored(obj.activity or '', 'yellow'))
class StatusFormatter(IFormatter):
MANDATORY_FIELDS = ('id',)

View file

@ -101,6 +101,7 @@ class ContactThread(QWidget):
return
self.ui.refreshButton.setEnabled(False)
def finished():
#v = self.ui.scrollArea.verticalScrollBar()
#print v.minimum(), v.value(), v.maximum(), v.sliderPosition()
@ -572,6 +573,7 @@ class ContactsWidget(QWidget):
def retrieveContact(self, url):
backend_name = unicode(self.ui.backendsList.currentText())
self.ui.urlButton.setEnabled(False)
def finished():
self.url_process = None
self.ui.urlButton.setEnabled(True)

View file

@ -66,6 +66,7 @@ class EventsWidget(QWidget):
self.ui.typeBox.setEnabled(False)
self.ui.typeBox.clear()
self.ui.typeBox.addItem('All', None)
def finished():
self.ui.refreshButton.setEnabled(True)
self.ui.typeBox.setEnabled(True)

View file

@ -56,12 +56,14 @@ class DeparturesFormatter(PrettyFormatter):
return s
class StationsFormatter(PrettyFormatter):
MANDATORY_FIELDS = ('id', 'name')
def get_title(self, obj):
return obj.name
class Traveloob(ReplApplication):
APPNAME = 'traveloob'
VERSION = '1.0'

View file

@ -527,6 +527,7 @@ class _PagesBrowserMeta(type):
new_class._urls.update(urls)
return new_class
class PagesBrowser(DomainBrowser):
r"""
A browser which works pages and keep state of navigation.
@ -680,6 +681,7 @@ class LoginBrowser(PagesBrowser):
"""
A browser which supports login.
"""
def __init__(self, username, password, *args, **kwargs):
super(LoginBrowser, self).__init__(*args, **kwargs)
self.username = username

View file

@ -42,6 +42,7 @@ def method(klass):
"""
Class-decorator to call it as a method.
"""
def inner(self, *args, **kwargs):
return klass(self)(*args, **kwargs)
return inner
@ -300,5 +301,3 @@ class TableElement(ListElement):
def get_colnum(self, name):
return self._cols.get(name, None)

View file

@ -131,4 +131,3 @@ class JSVar(Regexp):
return super(JSVar, self).filter(txt)
except RegexpError:
raise ParseError('Variable %r not found' % self.var)

View file

@ -32,6 +32,7 @@ from weboob.exceptions import ParseError
from weboob.browser.url import URL
from weboob.tools.log import getLogger, DEBUG_FILTERS
class NoDefault(object):
def __repr__(self):
return 'NO_DEFAULT'
@ -217,6 +218,7 @@ class Base(Filter):
>>> Base(Env('header'), CleanText('./h1')) # doctest: +SKIP
"""
def __call__(self, item):
base = self.select(self.base, item, obj=self._obj, key=self._key)
return self.selector(base)
@ -425,6 +427,7 @@ class Type(Filter):
>>> Type(type=str, minlen=0, default='a').filter('')
'a'
"""
def __init__(self, selector=None, type=None, minlen=0, default=_NO_DEFAULT):
super(Type, self).__init__(selector, default=default)
self.type_func = type

View file

@ -82,6 +82,7 @@ class NextPage(Exception):
See :meth:`PagesBrowser.pagination` or decorator :func:`pagination`.
"""
def __init__(self, request):
super(NextPage, self).__init__()
self.request = request
@ -122,17 +123,20 @@ class Page(object):
Event called when browser leaves this page.
"""
class FormNotFound(Exception):
"""
Raised when :meth:`HTMLPage.get_form` can't find a form.
"""
class FormSubmitWarning(UserWarning):
"""
A form has more than one submit element selected, and will likely
generate an invalid request.
"""
class Form(OrderedDict):
"""
Represents a form of an HTML page.

View file

@ -82,6 +82,7 @@ class Wget(Profile):
Some websites will give you a version with less JavaScript.
Some others could ban you (after all, wget is not a real browser).
"""
def __init__(self, version='1.11.4'):
self.version = version

View file

@ -34,6 +34,7 @@ from requests.sessions import merge_setting
from requests.structures import CaseInsensitiveDict
from requests.utils import get_netrc_auth
def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""
Properly merges both requests and session hooks.

View file

@ -201,5 +201,3 @@ class URL(object):
return func(browser, id_or_url, *args, **kwargs)
return inner

View file

@ -44,6 +44,7 @@ class CapAudioStream(CapAudio):
"""
Audio streams provider
"""
def search_audiostreams(self, pattern, sortby=CapFile.SEARCH_RELEVANCE):
"""
Search an audio stream

View file

@ -184,6 +184,7 @@ class CapBank(CapCollection):
"""
Capability of bank websites to see accounts and transactions.
"""
def iter_resources(self, objs, split_path):
"""
Iter resources.

View file

@ -45,6 +45,7 @@ def empty(value):
return True
return False
def find_object(mylist, error=None, **kwargs):
"""
Very simple tools to return an object with the matching parameters in
@ -63,6 +64,7 @@ def find_object(mylist, error=None, **kwargs):
raise error()
return None
class UserError(Exception):
"""
Exception containing an error message for user.
@ -78,6 +80,7 @@ class FieldNotFound(Exception):
:param field: field not found
:type field: :class:`Field`
"""
def __init__(self, obj, field):
Exception.__init__(self,
u'Field "%s" not found for object %s' % (field, obj))
@ -102,6 +105,7 @@ class NotAvailableType(object):
"""
NotAvailable is a constant to use on non available fields.
"""
def __str__(self):
return unicode(self).decode('utf-8')
@ -199,6 +203,7 @@ class IntField(Field):
"""
A field which accepts only :class:`int` and :class:`long` types.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, int, long, **kwargs)
@ -210,6 +215,7 @@ class DecimalField(Field):
"""
A field which accepts only :class:`decimal` type.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, Decimal, **kwargs)
@ -223,6 +229,7 @@ class FloatField(Field):
"""
A field which accepts only :class:`float` type.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, float, **kwargs)
@ -234,6 +241,7 @@ class StringField(Field):
"""
A field which accepts only :class:`unicode` strings.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, unicode, **kwargs)
@ -245,6 +253,7 @@ class BytesField(Field):
"""
A field which accepts only :class:`str` strings.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, str, **kwargs)

View file

@ -30,6 +30,7 @@ class SubscriptionNotFound(UserError):
"""
Raised when a subscription is not found.
"""
def __init__(self, msg='Subscription not found'):
UserError.__init__(self, msg)
@ -38,6 +39,7 @@ class BillNotFound(UserError):
"""
Raised when a bill is not found.
"""
def __init__(self, msg='Bill not found'):
UserError.__init__(self, msg)

View file

@ -236,6 +236,7 @@ class CapBugTracker(Capability):
"""
Bug trackers websites.
"""
def iter_issues(self, query):
"""
Iter issues with optionnal patterns.

View file

@ -57,6 +57,7 @@ class CapChat(Capability):
"""
Websites with a chat system.
"""
def iter_chat_messages(self, _id=None):
"""
Iter messages.

View file

@ -73,6 +73,7 @@ class CapCinema(Capability):
"""
Cinema databases.
"""
def iter_movies(self, pattern):
"""
Search movies and iterate on results.

View file

@ -39,6 +39,7 @@ class BaseCollection(BaseObject):
Inherit from this if you want to create an object that is *also* a Collection.
However, this probably will not work properly for now.
"""
def __init__(self, split_path):
BaseObject.__init__(self, None)
self.split_path = split_path

View file

@ -24,10 +24,12 @@ from weboob.capabilities.base import Field
__all__ = ['DateField', 'TimeField', 'DeltaField']
class DateField(Field):
"""
A field which accepts only :class:`datetime.date` and :class:`datetime.datetime` types.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, datetime.date, datetime.datetime, **kwargs)
@ -46,6 +48,7 @@ class TimeField(Field):
"""
A field which accepts only :class:`datetime.time` and :class:`datetime.time` types.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, datetime.time, datetime.datetime, **kwargs)
@ -54,5 +57,6 @@ class DeltaField(Field):
"""
A field which accepts only :class:`datetime.timedelta` type.
"""
def __init__(self, doc, **kwargs):
Field.__init__(self, doc, datetime.timedelta, **kwargs)

View file

@ -94,6 +94,7 @@ class CapDating(Capability):
"""
Capability for dating websites.
"""
def init_optimizations(self):
"""
Initialization of optimizations.
@ -155,4 +156,3 @@ class CapDating(Capability):
:rtype: iter[:class:`Contact`]
"""
raise NotImplementedError()

View file

@ -46,6 +46,7 @@ class CapGeolocIp(Capability):
"""
Access information about IP addresses database.
"""
def get_location(self, ipaddr):
"""
Get location of an IP address.

View file

@ -110,6 +110,7 @@ class CapHousing(Capability):
"""
Capability of websites to search housings.
"""
def search_housings(self, query):
"""
Search housings.

View file

@ -24,6 +24,7 @@ from .file import CapFile, BaseFile
__all__ = ['BaseImage', 'CapImage']
class _BaseImage(BaseFile):
"""
Fake class to allow the inclusion of a BaseImage property within
@ -31,6 +32,7 @@ class _BaseImage(BaseFile):
"""
pass
class BaseImage(_BaseImage):
"""
Represents an image file.
@ -61,6 +63,7 @@ class CapImage(CapFile):
"""
Image file provider
"""
def search_image(self, pattern, sortby=CapFile.SEARCH_RELEVANCE, nsfw=False):
"""
search for an image file
@ -83,4 +86,3 @@ class CapImage(CapFile):
:rtype: :class:`BaseImage`]
"""
return self.get_file(_id)

View file

@ -72,6 +72,7 @@ class CapJob(Capability):
"""
Capability of job annouce websites.
"""
def search_job(self, pattern=None):
"""
Iter results of a search on a pattern.

View file

@ -47,6 +47,7 @@ class CapBook(CapCollection):
"""
Library websites.
"""
def iter_resources(self, objs, split_path):
"""
Iter resources. It retuns :func:`iter_books`.

View file

@ -41,6 +41,7 @@ class CapLyrics(Capability):
"""
Lyrics websites.
"""
def iter_lyrics(self, criteria, pattern):
"""
Search lyrics by artist or by song

View file

@ -173,6 +173,7 @@ class CapMessages(Capability):
"""
Capability to read messages.
"""
def iter_threads(self):
"""
Iterates on threads, from newers to olders.
@ -217,6 +218,7 @@ class CapMessagesPost(Capability):
"""
This capability allow user to send a message.
"""
def post_message(self, message):
"""
Post a message.

View file

@ -62,5 +62,6 @@ class ParcelNotFound(UserError):
Raised when a parcell is not found.
It can be an user error, or an expired parcel
"""
def __init__(self, msg='Account not found'):
UserError.__init__(self, msg)

View file

@ -28,6 +28,7 @@ class PasteNotFound(UserError):
"""
Raised when a paste is not found.
"""
def __init__(self):
return super(PasteNotFound, self).__init__("Paste not found")

View file

@ -35,10 +35,12 @@ class Radio(BaseObject):
current = Field('Current emission', StreamInfo)
streams = Field('List of streams', list)
class CapRadio(Capability):
"""
Capability of radio websites.
"""
def iter_radios_search(self, pattern):
"""
Search a radio.

View file

@ -165,6 +165,7 @@ class CapRecipe(Capability):
"""
Recipe providers.
"""
def iter_recipes(self, pattern):
"""
Search recipes and iterate on results.

View file

@ -48,10 +48,12 @@ class Subtitle(BaseObject):
BaseObject.__init__(self, id)
self.name = name
class CapSubtitle(Capability):
"""
Subtitle providers.
"""
def iter_subtitles(self, pattern):
"""
Search subtitles and iterate on results.

View file

@ -29,6 +29,7 @@ class MagnetOnly(UserError):
"""
Raised when trying to get URL to torrent but only magnet is available.
"""
def __init__(self, magnet):
self.magnet = magnet
UserError.__init__(self, 'Only magnet URL is available')
@ -58,6 +59,7 @@ class CapTorrent(Capability):
"""
Torrent trackers.
"""
def iter_torrents(self, pattern):
"""
Search torrents and iterate on results.

View file

@ -99,6 +99,7 @@ class CapTravel(Capability):
"""
Travel websites.
"""
def iter_station_search(self, pattern):
"""
Iterates on search results of stations.

View file

@ -113,6 +113,7 @@ class CapWeather(Capability):
"""
Capability for weather websites.
"""
def iter_city_search(self, pattern):
"""
Look for a city.

View file

@ -103,6 +103,7 @@ class ModulesLoader(object):
"""
Load modules.
"""
def __init__(self, path, version=None):
self.version = version
self.path = path
@ -162,10 +163,12 @@ class ModulesLoader(object):
def get_module_path(self, module_name):
return self.path
class RepositoryModulesLoader(ModulesLoader):
"""
Load modules from repositories.
"""
def __init__(self, repositories):
super(RepositoryModulesLoader, self).__init__(repositories.modules_dir, repositories.version)
self.repositories = repositories

View file

@ -111,6 +111,7 @@ class WebNip(object):
:param backend_name: name of backend we can't load
:param exception: exception object
"""
def __init__(self, backend_name, exception):
Exception.__init__(self, unicode(exception))
self.backend_name = backend_name

View file

@ -45,6 +45,7 @@ class ModuleInfo(object):
"""
Information about a module available on a repository.
"""
def __init__(self, name):
self.name = name
@ -380,6 +381,7 @@ class IProgress(object):
def __repr__(self):
return '<%s>' % self.__class__.__name__
class PrintProgress(IProgress):
def progress(self, percent, message):
print('=== [%3.0f%%] %s' % (percent*100, message))
@ -450,6 +452,7 @@ class Repositories(object):
def load_browser(self):
from weboob.browser.browsers import Browser
from weboob.browser.profiles import Weboob as WeboobProfile
class WeboobBrowser(Browser):
PROFILE = WeboobProfile(self.version)
if self.browser is None:

View file

@ -69,6 +69,7 @@ class NoHistory(object):
"""
We don't want to fill memory with history
"""
def __init__(self):
pass
@ -703,6 +704,7 @@ class DNSTimeoutException(Exception):
cacheDNS = {}
def my_getaddrinfo(*args):
try:
res, timeout = cacheDNS[args]

View file

@ -29,6 +29,7 @@ class Csv(object):
rows contains the raw rows
drows contains the rows with cells indexed by header title
"""
def __init__(self):
self.header = None
self.rows = []

View file

@ -109,6 +109,7 @@ class LxmlHtmlParser(LxmlParser):
Note that it is not available on every systems.
"""
def __init__(self, *args, **kwargs):
self.module = html
@ -122,6 +123,7 @@ class LxmlXmlParser(LxmlParser):
Note that it is not available on every systems.
"""
def __init__(self, *args, **kwargs):
self.module = etree

View file

@ -47,6 +47,7 @@ class JsonFormatter(IFormatter):
"""
Formats the whole list as a single JSON list object.
"""
def __init__(self):
IFormatter.__init__(self)
self.queue = []
@ -66,9 +67,11 @@ class JsonLineFormatter(IFormatter):
Formats the list as received, with a JSON object per line.
The advantage is that it can be streamed.
"""
def format_dict(self, item):
self.output(json.dumps(item, cls=Encoder))
def test():
from .iformatter import formatter_test_output as fmt
assert fmt(JsonFormatter, {'foo': 'bar'}) == '[{"foo": "bar"}]\n'

View file

@ -100,6 +100,7 @@ class TableFormatter(IFormatter):
class HTMLTableFormatter(TableFormatter):
HTML = True
def test():
from .iformatter import formatter_test_output as fmt
assert fmt(TableFormatter, {'foo': 'bar'}) == \

View file

@ -61,6 +61,7 @@ class MediaPlayer(object):
world, the media player used is chosen from a static list of
programs. See PLAYERS for more information.
"""
def __init__(self, logger=None):
self.logger = getLogger('mediaplayer', logger)

View file

@ -178,6 +178,7 @@ class QtApplication(QApplication, Application):
QMessageBox.information(None, self.tr('Update of repositories'),
self.tr('Repositories updated!'), QMessageBox.Ok)
class QtMainWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)

View file

@ -44,6 +44,7 @@ class BackendStorage(object):
:param storage: storage object
:type storage: :class:`weboob.tools.storage.IStorage`
"""
def __init__(self, name, storage):
self.name = name
self.storage = storage

View file

@ -38,6 +38,7 @@ __all__ = ['FrenchTransaction', 'AmericanTransaction']
class classproperty(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, owner):
return self.f(owner)
@ -225,6 +226,7 @@ class FrenchTransaction(Transaction):
@classmethod
def Raw(klass, *args, **kwargs):
patterns = klass.PATTERNS
class Filter(CleanText):
def __call__(self, item):
raw = super(Filter, self).__call__(item)
@ -286,6 +288,7 @@ class FrenchTransaction(Transaction):
break
return raw
def filter(self, text):
text = super(Filter, self).filter(text)
return to_unicode(text.replace(u'\n', u' ').strip())
@ -332,6 +335,7 @@ class AmericanTransaction(Transaction):
text = text.replace(',', ' ').replace('.', ',')
return FrenchTransaction.clean_amount(text)
def test():
clean_amount = AmericanTransaction.clean_amount
assert clean_amount('42') == '42'

View file

@ -70,6 +70,7 @@ def image_mime(data_base64, supported_formats=('gif', 'jpeg', 'png')):
'MM\x2a\x00' in beginning):
return 'image/tiff'
def test():
class MockPasteModule(BasePasteModule):
def __init__(self, expirations):

View file

@ -39,4 +39,3 @@ class StreamInfo(BaseObject):
return u'%s - %s' % (self.who, self.what)
else:
return self.what

View file

@ -214,6 +214,7 @@ class ChaoticDateGuesser(LinearDateGuesser):
This class aim to find the guess the date when you know the
day and month and the minimum year
"""
def __init__(self, min_date, current_date=None, date_max_bump=timedelta(7)):
if min_date is None:
raise ValueError("min_date is not set")

View file

@ -59,6 +59,7 @@ class ColoredFormatter(Formatter):
Class written by airmind:
http://stackoverflow.com/questions/384076/how-can-i-make-the-python-logging-output-to-be-colored
"""
def format(self, record):
levelname = record.levelname
msg = Formatter.format(self, record)

View file

@ -50,6 +50,7 @@ ESCAPE_MAPPINGS = {
"Z": None,
}
class Choice(list):
"""
Used to represent multiple possibilities at this point in a pattern string.
@ -57,16 +58,19 @@ class Choice(list):
code is clear.
"""
class Group(list):
"""
Used to represent a capturing group in the pattern string.
"""
class NonCapture(list):
"""
Used to represent a non-capturing group in the pattern string.
"""
def normalize(pattern):
"""
Given a reg-exp pattern, normalizes it to a list of forms that suffice for
@ -222,6 +226,7 @@ def normalize(pattern):
return zip(*flatten_result(result))
def next_char(input_iter):
"""
An iterator that yields the next character from "pattern_iter", respecting
@ -242,6 +247,7 @@ def next_char(input_iter):
continue
yield representative, True
def walk_to_end(ch, input_iter):
"""
The iterator is currently inside a capturing group. We want to walk to the
@ -262,6 +268,7 @@ def walk_to_end(ch, input_iter):
return
nesting -= 1
def get_quantifier(ch, input_iter):
"""
Parse a quantifier from the input, where "ch" is the first character in the
@ -298,6 +305,7 @@ def get_quantifier(ch, input_iter):
ch = None
return int(values[0]), ch
def contains(source, inst):
"""
Returns True if the "source" contains an instance of "inst". False,
@ -311,6 +319,7 @@ def contains(source, inst):
return True
return False
def flatten_result(source):
"""
Turns the given source sequence into a list of reg-exp possibilities and
@ -363,4 +372,3 @@ def flatten_result(source):
for i in range(len(result)):
result[i] += piece
return result, result_args

View file

@ -33,6 +33,7 @@ class ValuesDict(OrderedDict):
>>> ValuesDict(Value('a', label='Test'), ValueInt('b', label='Test2'))
"""
def __init__(self, *values):
OrderedDict.__init__(self)
for v in values: