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

@ -30,7 +30,9 @@ from weboob.core import Weboob
from weboob.capabilities.video import CapVideo
# hack to workaround bash redirection and encoding problem
import sys, codecs, locale
import sys
import codecs
import locale
if sys.stdout.encoding is None:
(lang, enc) = locale.getdefaultlocale()

View file

@ -102,17 +102,17 @@ class BoobankMuninPlugin(object):
if check and (last + self.cache_expire) < time.time():
return False
for line in f.xreadlines():
for line in f:
sys.stdout.write(line)
return True
def new_cache(self, name):
os.umask(0077)
os.umask(0o077)
new_name = '%s.new' % name
filename = self.cachepath(new_name)
try:
f = open(filename, 'w')
except IOError, e:
except IOError as e:
print >>sys.stderr, 'Unable to create the cache file %s: %s' % (filename, e)
return
@ -166,7 +166,7 @@ class BoobankMuninPlugin(object):
self.write_output('%s.label %s' % (id, account.label.encode('iso-8859-15')))
if self.cumulate:
self.write_output('%s.draw %s' % (id, type))
except CallErrors, errors:
except CallErrors as errors:
self.print_errors(errors)
self.print_cache('boobank-munin-config')
else:
@ -197,7 +197,7 @@ class BoobankMuninPlugin(object):
if account.coming and self.add_coming:
balance += account.coming
self.write_output('%s.value %d' % (self.account2id(account), balance))
except CallErrors, errors:
except CallErrors as errors:
self.print_errors(errors)
self.print_cache('boobank-munin')
else:

View file

@ -191,17 +191,17 @@ class GenericMuninPlugin(object):
if check and (last + self.cache_expire) < time.time():
return False
for line in f.xreadlines():
for line in f:
sys.stdout.write(line)
return True
def new_cache(self, name):
os.umask(0077)
os.umask(0o077)
new_name = '%s.new' % name
filename = self.cachepath(new_name)
try:
f = open(filename, 'w')
except IOError, e:
except IOError as e:
print >>sys.stderr, 'Unable to create the cache file %s: %s' % (filename, e)
return
@ -310,7 +310,7 @@ class GenericMuninPlugin(object):
self.write_output('%s.label %s' % (id.encode('iso-8859-15'), getattr(result, self.attriblabel).encode('iso-8859-15')))
if self.cumulate:
self.write_output('%s.draw %s' % (id, type))
except CallErrors, errors:
except CallErrors as errors:
self.print_errors(errors)
self.print_cache('%s-config' % self.name)
else:
@ -334,7 +334,7 @@ class GenericMuninPlugin(object):
value = self.get_value(result)
if value is not NotAvailable:
self.write_output('%s.value %f' % (self.result2id(result).encode('iso-8859-15'), value))
except CallErrors, errors:
except CallErrors as errors:
self.print_errors(errors)
self.print_cache(self.name)
else: