PEP8 style fixes and other small style fixes

I used autopep8 on some files and did carefully check the changes.
I ignored E501,E302,E231,E225,E222,E221,E241,E203 in my search, and at
least E501 on any autopep8 run.

Other style fixes not related to PEP8:
* Only use new-style classes. I don't think the usage of old-style
  classes was voluntary. Old-style classes are removed in Python 3.
* Convert an if/else to a one-liner in mediawiki, change docstring style
  change to a comment something that wasn't really appropriate for a
  docstring.
* Unneeded first if condition in meteofrance
This commit is contained in:
Laurent Bachelier 2012-03-14 03:24:02 +01:00
commit 006e97a8be
99 changed files with 441 additions and 350 deletions

View file

@ -1 +0,0 @@

View file

@ -49,6 +49,7 @@ class QifFormatter(IFormatter):
self.count += 1
return result
class TransactionsFormatter(IFormatter):
MANDATORY_FIELDS = ('date', 'label', 'amount')
TYPES = ['', 'Transfer', 'Order', 'Check', 'Deposit', 'Payback', 'Withdrawal', 'Card', 'Loan', 'Bank']
@ -82,6 +83,7 @@ class TransactionsFormatter(IFormatter):
result += ' %-10s %-12s %-50s %10.2f' % (item['date'].strftime('%Y-%m-%d'), _type, label[:50], item['amount'])
return result
class TransferFormatter(IFormatter):
MANDATORY_FIELDS = ('id', 'date', 'origin', 'recipient', 'amount')
@ -96,6 +98,7 @@ class TransferFormatter(IFormatter):
result += u'Amount: %.2f\n' % item['amount']
return result
class RecipientListFormatter(IFormatter):
MANDATORY_FIELDS = ('id', 'label')
@ -115,6 +118,7 @@ class RecipientListFormatter(IFormatter):
return u'%s %-30s %s %s' % (self.BOLD, id, self.NC, item['label'])
class AccountListFormatter(IFormatter):
MANDATORY_FIELDS = ('id', 'label', 'balance', 'coming')
@ -122,13 +126,12 @@ class AccountListFormatter(IFormatter):
tot_balance = 0.0
tot_coming = 0.0
def flush(self):
if self.count < 1:
return
result = u'------------------------------------------%s+----------+----------\n' % (('-' * 15) if not self.interactive else '')
result +=u'%s Total %8s %8s' % ((' ' * 15) if not self.interactive else '',
result += u'%s Total %8s %8s' % ((' ' * 15) if not self.interactive else '',
'%.2f' % self.tot_balance, '%.2f' % self.tot_coming)
self.after_format(result)
self.tot_balance = 0.0
@ -156,6 +159,7 @@ class AccountListFormatter(IFormatter):
self.tot_coming += item['coming']
return result
class Boobank(ReplApplication):
APPNAME = 'boobank'
VERSION = '0.b'
@ -278,7 +282,7 @@ class Boobank(ReplApplication):
try:
amount = float(amount)
except (TypeError,ValueError):
except (TypeError, ValueError):
print >>sys.stderr, 'Error: please give a decimal amount to transfer'
return 2

View file

@ -124,7 +124,7 @@ class MasstransitHildon():
self.main_window.connect("destroy", self.on_main_window_destroy)
self.refresh_button.connect("clicked", self.on_refresh_button_clicked)
self.retour_button.set_sensitive(False)
self.retour_button.connect("clicked", self.on_retour_button_clicked)
@ -165,8 +165,8 @@ class MasstransitHildon():
text=4
))
vertical_box = gtk.VBox()
vertical_box.pack_start(horizontal_box)
horizontal_box.pack_start(self.retour_button)
@ -187,7 +187,7 @@ class MasstransitHildon():
def fill_touch_selector_entry(self):
liste = []
for backend in self.weboob.iter_backends():
for station in backend.iter_station_search(""):
liste.append(station.name.capitalize())
@ -272,7 +272,7 @@ class MasstransitHildon():
self.refresh_in_progress = False
banner.set_timeout(1)
hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 0)
hildon.hildon_gtk_window_set_progress_indicator(self.main_window, 0)
class Masstransit(BaseApplication):

View file

@ -1,3 +1,4 @@
from .qwebcontentedit import QWebContentEdit
__all__ = ['QWebContentEdit']
__all__ = ['QWebContentEdit']

View file

@ -22,6 +22,7 @@ from weboob.capabilities.content import ICapContent
from .main_window import MainWindow
class QWebContentEdit(QtApplication):
APPNAME = 'qwebcontentedit'
VERSION = '0.b'
@ -34,5 +35,3 @@ class QWebContentEdit(QtApplication):
self.main_window = MainWindow(self.config, self.weboob)
self.main_window.show()
return self.weboob.loop()

View file

@ -124,8 +124,8 @@ class WeboobRepos(ReplApplication):
'--keyring', os.path.realpath(krname),
'--import', os.path.realpath(keypath)])
# Does not make much sense in our case
if os.path.exists(krname+'~'):
os.remove(krname+'~')
if os.path.exists(krname + '~'):
os.remove(krname + '~')
if not os.path.exists(krname):
raise Exception('No valid key file found.')
kr_mtime = mktime(strptime(str(r.key_update), '%Y%m%d%H%M'))
@ -134,7 +134,6 @@ class WeboobRepos(ReplApplication):
else:
print 'Keyring is up to date'
for name, module in r.modules.iteritems():
tarname = os.path.join(repo_path, '%s.tar.gz' % name)
if r.signed:
@ -185,7 +184,7 @@ class WeboobRepos(ReplApplication):
# Check if all files have an up to date signature
for filename in sigfiles:
filepath = os.path.realpath(os.path.join(repo_path, filename))
sigpath = filepath+'.sig'
sigpath = filepath + '.sig'
file_mtime = int(os.path.getmtime(filepath))
if os.path.exists(sigpath):
sig_mtime = int(os.path.getmtime(sigpath))
@ -202,7 +201,6 @@ class WeboobRepos(ReplApplication):
os.utime(sigpath, (file_mtime, file_mtime))
print 'Signatures are up to date'
@staticmethod
def _find_gpg():
if os.getenv('GPG_EXECUTABLE'):
@ -221,4 +219,3 @@ class WeboobRepos(ReplApplication):
if filename.endswith('.png'):
return True
return False