pep8 fixes, modernizations

autopep8 -a -r -i --select E711,E712,W601,W602,W603,W604,W690,E304,E401,E502 .
Also includes some manual reindentations (many are left after the print()
changes).
Manually checked, some modernizations not commited here.
This commit is contained in:
Laurent Bachelier 2014-10-10 22:10:41 +02:00
commit 6161a0aacd
18 changed files with 57 additions and 51 deletions

View file

@ -19,7 +19,8 @@
from __future__ import print_function
import datetime, uuid
import datetime
import uuid
from dateutil.relativedelta import relativedelta
from dateutil.parser import parse as parse_date
from decimal import Decimal, InvalidOperation
@ -334,8 +335,8 @@ class Boobank(ReplApplication):
try:
end_date = parse_date(end_date)
except ValueError:
print('"%s" is an incorrect date format (for example "%s")' % \
(end_date, (datetime.date.today() - relativedelta(months=1)).strftime('%Y-%m-%d')), file=self.stderr)
print('"%s" is an incorrect date format (for example "%s")' %
(end_date, (datetime.date.today() - relativedelta(months=1)).strftime('%Y-%m-%d')), file=self.stderr)
return 3
old_count = self.options.count
self.options.count = None

View file

@ -424,7 +424,7 @@ class Cineoob(ReplApplication):
self.start_format()
self.format(movie)
#================== TORRENT ==================
# ================== TORRENT ==================
def complete_info_torrent(self, text, line, *ignored):
args = line.split(' ')
@ -484,9 +484,9 @@ class Cineoob(ReplApplication):
except CallErrors as errors:
for backend, error, backtrace in errors:
if isinstance(error, MagnetOnly):
print(u'Error(%s): No direct URL available, ' \
u'please provide this magnet URL ' \
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
print(u'Error(%s): No direct URL available, '
u'please provide this magnet URL '
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
return 4
else:
self.bcall_error_handler(backend, error, backtrace)
@ -531,7 +531,7 @@ class Cineoob(ReplApplication):
for torrent in self.do('iter_torrents', pattern=pattern, caps=CapTorrent):
self.cached_format(torrent)
#================== SUBTITLE ==================
# ================== SUBTITLE ==================
def complete_info_subtitle(self, text, line, *ignored):
args = line.split(' ')

View file

@ -162,9 +162,9 @@ class Weboorrents(ReplApplication):
except CallErrors as errors:
for backend, error, backtrace in errors:
if isinstance(error, MagnetOnly):
print(u'Error(%s): No direct URL available, ' \
u'please provide this magnet URL ' \
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
print(u'Error(%s): No direct URL available, '
u'please provide this magnet URL '
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
return 4
else:
self.bcall_error_handler(backend, error, backtrace)

View file

@ -207,7 +207,7 @@ class _ItemElementMeta(type):
filters = [(re.sub('^obj_', '', attr_name), attrs[attr_name]) for attr_name, obj in attrs.items() if attr_name.startswith('obj_')]
# constants first, then filters, then methods
filters.sort(key=lambda x: x[1]._creation_counter if hasattr(x[1], '_creation_counter') else (sys.maxint if callable(x[1]) else 0))
filters.sort(key=lambda x: x[1]._creation_counter if hasattr(x[1], '_creation_counter') else (sys.maxsize if callable(x[1]) else 0))
new_class = super(_ItemElementMeta, mcs).__new__(mcs, name, bases, attrs)
new_class._attrs = _attrs + [f[0] for f in filters]

View file

@ -520,7 +520,7 @@ class ConsoleApplication(Application):
text = f.read()
else:
if self.stdin.isatty():
print('Reading content from stdin... Type ctrl-D ' \
print('Reading content from stdin... Type ctrl-D '
'from an empty line to stop.')
text = self.stdin.read()
return text.decode(self.encoding)

View file

@ -204,7 +204,7 @@ class ReplApplication(Cmd, ConsoleApplication):
print('This command works with an unique backend. Availables:')
for index, (name, backend) in enumerate(e.backends):
print('%s%d)%s %s%-15s%s %s' % (self.BOLD, index + 1, self.NC, self.BOLD, name, self.NC,
backend.DESCRIPTION))
backend.DESCRIPTION))
i = self.ask('Select a backend to proceed with "%s"' % id)
if not i.isdigit():
if not i in dict(e.backends):
@ -925,8 +925,8 @@ class ReplApplication(Cmd, ConsoleApplication):
self.commands_formatters = {}
self.DEFAULT_FORMATTER = self.set_formatter(args[0])
else:
print('Formatter "%s" is not available.\n' \
'Available formatters: %s.' % (args[0], ', '.join(self.formatters_loader.get_available_formatters())), file=self.stderr)
print('Formatter "%s" is not available.\n'
'Available formatters: %s.' % (args[0], ', '.join(self.formatters_loader.get_available_formatters())), file=self.stderr)
return 1
else:
print('Default formatter: %s' % self.DEFAULT_FORMATTER)

View file

@ -66,7 +66,7 @@ def image_mime(data_base64, supported_formats=('gif', 'jpeg', 'png')):
return 'image/x-xcf'
elif 'pdf' in supported_formats and '%PDF' in beginning:
return 'application/pdf'
elif 'tiff' in supported_formats and ('II\x00\x2a' in beginning or \
elif 'tiff' in supported_formats and ('II\x00\x2a' in beginning or
'MM\x2a\x00' in beginning):
return 'image/tiff'

View file

@ -222,9 +222,9 @@ class GridVirtKeyboard(VirtKeyboard):
tileW = float(self.width) / cols
tileH = float(self.height) / rows
positions = ((s, i * tileW % self.width, i / cols * tileH) \
positions = ((s, i * tileW % self.width, i / cols * tileH)
for i, s in enumerate(symbols))
coords = dict((s, tuple(map(int, (x, y, x + tileW, y + tileH)))) \
coords = dict((s, tuple(map(int, (x, y, x + tileW, y + tileH))))
for (s, x, y) in positions)
super(GridVirtKeyboard, self).__init__()