Easy spacing fixes, trailing stuff

Remove useless trailing \
Remove trailing spaces
Add missing empty lines

autopep8 -ir -j2 --select=E301,E302,E502,W291,W293,W391 .

Diff quickly checked.
This commit is contained in:
Laurent Bachelier 2013-03-15 20:01:49 +01:00
commit 7094931c92
231 changed files with 474 additions and 67 deletions

View file

@ -64,6 +64,7 @@ class ApplicationStorage(object):
if self.storage:
return self.storage.save('applications', self.name)
class BaseApplication(object):
"""
Base application.

View file

@ -50,9 +50,11 @@ class BackendNotGiven(Exception):
Exception.__init__(self, 'Please specify a backend to use for this argument (%s@backend_name). '
'Availables: %s.' % (id, ', '.join(name for name, backend in backends)))
class BackendNotFound(Exception):
pass
class ConsoleApplication(BaseApplication):
"""
Base application class for CLI applications.

View file

@ -24,6 +24,7 @@ __all__ = ['FormattersLoader', 'FormatterLoadError']
class FormatterLoadError(Exception):
pass
class FormattersLoader(object):
BUILTINS = ['htmltable', 'multiline', 'simple', 'table', 'csv', 'webkit', 'json']

View file

@ -70,7 +70,7 @@ class TableFormatter(IFormatter):
table = PrettyTable(list(column_headers))
for column_header in column_headers:
# API changed in python-prettytable. The try/except is a bad hack to support both versions
# Note: two versions are not exactly the same...
# Note: two versions are not exactly the same...
# (first one: header in center. Second one: left align for header too)
try:
table.set_field_align(column_header, 'l')

View file

@ -39,7 +39,7 @@ PLAYERS = (
class MediaPlayerNotFound(Exception):
def __init__(self):
Exception.__init__(self, u'No media player found on this system. Please install one of them: %s.' % \
Exception.__init__(self, u'No media player found on this system. Please install one of them: %s.' %
', '.join(player[0] for player in PLAYERS))
@ -75,7 +75,7 @@ class MediaPlayer(object):
"""
player_names = [player[0] for player in PLAYERS]
if not player_name:
self.logger.debug(u'No media player given. Using the first available from: %s.' % \
self.logger.debug(u'No media player given. Using the first available from: %s.' %
', '.join(player_names))
player_name = self.guess_player_name()
if player_name is None:

View file

@ -221,7 +221,7 @@ class BackendCfg(QDialog):
continue
item = QTreeWidgetItem(None, [instance_name, name])
item.setCheckState(0, Qt.Checked if params.get('_enabled', '1').lower() in ('1', 'y', 'true') \
item.setCheckState(0, Qt.Checked if params.get('_enabled', '1').lower() in ('1', 'y', 'true')
else Qt.Unchecked)
self.set_icon(item, info)

View file

@ -39,6 +39,7 @@ from ..base import BaseApplication
__all__ = ['QtApplication', 'QtMainWindow', 'QtDo', 'HTMLDelegate']
class QtScheduler(IScheduler):
def __init__(self, app):
self.app = app
@ -81,6 +82,7 @@ class QtScheduler(IScheduler):
def run(self):
self.app.exec_()
class QCallbacksManager(QObject):
class Request(object):
def __init__(self):
@ -132,6 +134,7 @@ class QCallbacksManager(QObject):
request.event.wait()
return request.answer
class QtApplication(QApplication, BaseApplication):
def __init__(self):
QApplication.__init__(self, sys.argv)
@ -143,10 +146,12 @@ class QtApplication(QApplication, BaseApplication):
def create_weboob(self):
return Weboob(scheduler=QtScheduler(self))
class QtMainWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
class QtDo(QObject):
def __init__(self, weboob, cb, eb=None):
QObject.__init__(self)
@ -223,6 +228,7 @@ class QtDo(QObject):
def thread_eb(self, backend, error, backtrace):
self.emit(SIGNAL('eb'), backend, error, backtrace)
class HTMLDelegate(QStyledItemDelegate):
def paint(self, painter, option, index):
optionV4 = QStyleOptionViewItemV4(option)
@ -260,6 +266,7 @@ class HTMLDelegate(QStyledItemDelegate):
return QSize(doc.idealWidth(), max(doc.size().height(), optionV4.decorationSize.height()))
class _QtValueStr(QLineEdit):
def __init__(self, value):
QLineEdit.__init__(self)
@ -277,11 +284,13 @@ class _QtValueStr(QLineEdit):
self._value.set(unicode(self.text()))
return self._value
class _QtValueBackendPassword(_QtValueStr):
def get_value(self):
self._value._domain = None
return _QtValueStr.get_value(self)
class _QtValueBool(QCheckBox):
def __init__(self, value):
QCheckBox.__init__(self)
@ -297,6 +306,7 @@ class _QtValueBool(QCheckBox):
self._value.set(self.isChecked())
return self._value
class _QtValueInt(QSpinBox):
def __init__(self, value):
QSpinBox.__init__(self)
@ -312,6 +322,7 @@ class _QtValueInt(QSpinBox):
self._value.set(self.getValue())
return self._value
class _QtValueChoices(QComboBox):
def __init__(self, value):
QComboBox.__init__(self)
@ -332,6 +343,7 @@ class _QtValueChoices(QComboBox):
self._value.set(unicode(self.itemData(self.currentIndex()).toString()))
return self._value
def QtValue(value):
if isinstance(value, ValueBool):
klass = _QtValueBool

View file

@ -70,12 +70,15 @@ __all__ = ['BrowserIncorrectPassword', 'BrowserForbidden', 'BrowserBanned', 'Bro
class BrowserIncorrectPassword(Exception):
pass
class BrowserForbidden(Exception):
pass
class BrowserBanned(BrowserIncorrectPassword):
pass
class BrowserPasswordExpired(BrowserIncorrectPassword):
pass
@ -83,9 +86,11 @@ class BrowserPasswordExpired(BrowserIncorrectPassword):
class BrowserUnavailable(Exception):
pass
class BrowserHTTPNotFound(BrowserUnavailable):
pass
class BrowserHTTPError(BrowserUnavailable):
pass
@ -113,9 +118,11 @@ class NoHistory(object):
def close(self):
pass
class BrokenPageError(Exception):
pass
class BasePage(object):
"""
Base page
@ -138,6 +145,7 @@ class BasePage(object):
"""
pass
def check_location(func):
def inner(self, *args, **kwargs):
if args and isinstance(args[0], basestring):
@ -152,6 +160,7 @@ def check_location(func):
return func(self, *args, **kwargs)
return inner
class StandardBrowser(mechanize.Browser):
"""
Standard Browser.

View file

@ -23,6 +23,7 @@ __all__ = ['check_url', 'id2url']
from urlparse import urlsplit
import re
class check_url(object):
"""
Checks if the first argument matches the given regular expression (given as str,

View file

@ -50,6 +50,8 @@ def drop_comments(base_element):
# Replace relative url in link and image with a complete url
# Arguments: the html element to clean, and the domain name (with http:// prefix)
def clean_relativ_urls(base_element, domain):
for a in base_element.findall('.//a'):
if "href" in a.attrib:

View file

@ -48,6 +48,7 @@ class BasePasteBackend(ICapPaste):
if max_age is False or max_age >= e:
return e
def test():
class MockPasteBackend(BasePasteBackend):
def __init__(self, expirations):

View file

@ -46,10 +46,10 @@ class VirtKeyboard(object):
self.bands = img.getbands()
if isinstance(color, int) and not isinstance(self.bands, str) and len(self.bands) != 1:
raise VirtKeyboardError("Color requires %i component but only 1 is provided" \
raise VirtKeyboardError("Color requires %i component but only 1 is provided"
% len(self.bands))
if not isinstance(color, int) and len(color) != len(self.bands):
raise VirtKeyboardError("Color requires %i components but %i are provided" \
raise VirtKeyboardError("Color requires %i components but %i are provided"
% (len(self.bands), len(color)))
self.color = color
@ -123,7 +123,7 @@ class VirtKeyboard(object):
if dirname is None:
dirname = tempfile.mkdtemp(prefix='weboob_session_')
self.generate_MD5(dirname)
raise VirtKeyboardError("Symbol '%s' not found; all symbol hashes are available in %s"\
raise VirtKeyboardError("Symbol '%s' not found; all symbol hashes are available in %s"
% (s, dirname))
def generate_MD5(self, dir):

View file

@ -54,6 +54,7 @@ class IParser(object):
p = re.compile(r'<.*?>')
return p.sub(' ', data).strip()
class RawParser(IParser):
def parse(self, data, encoding=None):
return data.read()

View file

@ -26,6 +26,7 @@ from weboob.core import Weboob
__all__ = ['TestCase', 'BackendTest']
class BackendTest(TestCase):
BACKEND = None

View file

@ -37,6 +37,7 @@ class ValuesDict(OrderedDict):
for v in values:
self[v.id] = v
class Value(object):
"""
Value.
@ -116,6 +117,7 @@ class Value(object):
"""
return self._value
class ValueBackendPassword(Value):
_domain = None
_callbacks = {}
@ -190,6 +192,7 @@ class ValueBackendPassword(Value):
self._stored = False
return self._value
class ValueInt(Value):
def __init__(self, *args, **kwargs):
kwargs['regexp'] = '^\d+$'
@ -198,6 +201,7 @@ class ValueInt(Value):
def get(self):
return int(self._value)
class ValueFloat(Value):
def __init__(self, *args, **kwargs):
kwargs['regexp'] = '^[\d\.]+$'
@ -212,6 +216,7 @@ class ValueFloat(Value):
def get(self):
return float(self._value)
class ValueBool(Value):
def __init__(self, *args, **kwargs):
kwargs['choices'] = {'y': 'True', 'n': 'False'}