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:
parent
1e000acf3a
commit
006e97a8be
99 changed files with 441 additions and 350 deletions
|
|
@ -298,7 +298,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
yield thread.root
|
||||
except BrowserUnavailable, e:
|
||||
self.logger.debug('No messages, browser is unavailable: %s' % e)
|
||||
pass # don't care about waiting
|
||||
pass # don't care about waiting
|
||||
|
||||
def set_message_read(self, message):
|
||||
if message.id == self.MAGIC_ID_BASKET:
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import Image
|
|||
|
||||
class CaptchaError(Exception): pass
|
||||
|
||||
class Tile:
|
||||
class Tile(object):
|
||||
hash = {
|
||||
'bc8d52d96058478a6def26226145d53b': 'A',
|
||||
'c62ecdfddb72b2feaed96cd9fe7c2802': 'A',
|
||||
|
|
@ -111,7 +111,7 @@ class Tile:
|
|||
print 'hash: %s' % checksum
|
||||
raise CaptchaError()
|
||||
|
||||
class Captcha:
|
||||
class Captcha(object):
|
||||
def __init__(self, f):
|
||||
self.img = Image.open(f)
|
||||
self.w, self.h = self.img.size
|
||||
|
|
@ -152,7 +152,7 @@ class Captcha:
|
|||
s += tile.letter
|
||||
return s
|
||||
|
||||
class Decoder:
|
||||
class Decoder(object):
|
||||
def __init__(self):
|
||||
self.hash = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ from weboob.tools.ordereddict import OrderedDict
|
|||
from weboob.capabilities.contact import Contact as _Contact, ProfileNode
|
||||
from weboob.tools.misc import html2text
|
||||
|
||||
class FieldBase:
|
||||
|
||||
class FieldBase(object):
|
||||
def __init__(self, key, key2=None):
|
||||
self.key = key
|
||||
self.key2 = key2
|
||||
|
|
@ -34,18 +35,22 @@ class FieldBase:
|
|||
def get_value(self, value, consts):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class FieldStr(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
return html2text(unicode(profile[self.key])).strip()
|
||||
|
||||
|
||||
class FieldBool(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
return bool(int(profile[self.key]))
|
||||
|
||||
|
||||
class FieldDist(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
return '%.2f km' % float(profile[self.key])
|
||||
|
||||
|
||||
class FieldIP(FieldBase):
|
||||
def get_hostname(self, s):
|
||||
try:
|
||||
|
|
@ -59,6 +64,7 @@ class FieldIP(FieldBase):
|
|||
s += ' (first %s)' % self.get_hostname(profile[self.key2])
|
||||
return s
|
||||
|
||||
|
||||
class FieldProfileURL(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
id = int(profile[self.key])
|
||||
|
|
@ -67,10 +73,12 @@ class FieldProfileURL(FieldBase):
|
|||
else:
|
||||
return ''
|
||||
|
||||
|
||||
class FieldPopu(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
return unicode(profile['popu'][self.key])
|
||||
|
||||
|
||||
class FieldPopuRatio(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
v1 = float(profile['popu'][self.key])
|
||||
|
|
@ -80,15 +88,18 @@ class FieldPopuRatio(FieldBase):
|
|||
else:
|
||||
return '%.2f' % (v1 / v2)
|
||||
|
||||
|
||||
class FieldOld(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
birthday = parse_dt(profile[self.key])
|
||||
return int((datetime.now() - birthday).days / 365.25)
|
||||
|
||||
|
||||
class FieldSplit(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
return [html2text(s).strip() for s in profile[self.key].split(self.key2) if len(s.strip()) > 0]
|
||||
|
||||
|
||||
class FieldBMI(FieldBase):
|
||||
def __init__(self, key, key2, fat=False):
|
||||
FieldBase.__init__(self, key, key2)
|
||||
|
|
@ -100,7 +111,7 @@ class FieldBMI(FieldBase):
|
|||
if height == 0 or weight == 0:
|
||||
return ''
|
||||
|
||||
bmi = (weight/float(pow(height/100.0, 2)))
|
||||
bmi = (weight / float(pow(height / 100.0, 2)))
|
||||
if not self.fat:
|
||||
return bmi
|
||||
elif bmi < 15.5:
|
||||
|
|
@ -114,6 +125,7 @@ class FieldBMI(FieldBase):
|
|||
else:
|
||||
return 'obese'
|
||||
|
||||
|
||||
class FieldFlags(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
i = int(profile[self.key])
|
||||
|
|
@ -123,6 +135,7 @@ class FieldFlags(FieldBase):
|
|||
labels.append(html2text(d['label']).strip())
|
||||
return labels
|
||||
|
||||
|
||||
class FieldList(FieldBase):
|
||||
def get_value(self, profile, consts):
|
||||
i = int(profile[self.key])
|
||||
|
|
@ -131,6 +144,7 @@ class FieldList(FieldBase):
|
|||
return html2text(d['label']).strip()
|
||||
return ''
|
||||
|
||||
|
||||
class Contact(_Contact):
|
||||
TABLE = OrderedDict((
|
||||
('_info', OrderedDict((
|
||||
|
|
@ -247,9 +261,9 @@ class Contact(_Contact):
|
|||
if node.flags & node.SECTION:
|
||||
result += u'\t' * level + node.label + '\n'
|
||||
for sub in node.value.itervalues():
|
||||
result += print_node(sub, level+1)
|
||||
result += print_node(sub, level + 1)
|
||||
else:
|
||||
if isinstance(node.value, (tuple,list)):
|
||||
if isinstance(node.value, (tuple, list)):
|
||||
value = ', '.join(unicode(v) for v in node.value)
|
||||
elif isinstance(node.value, float):
|
||||
value = '%.2f' % node.value
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ class PriorityConnection(Optimization):
|
|||
browser = AuMBrowser('%s@%s' % (name, self.config['domain']), proxy=self.browser.proxy)
|
||||
try:
|
||||
browser.register(password= password,
|
||||
sex= 1, #slut
|
||||
birthday_d= random.randint(1,28),
|
||||
birthday_m= random.randint(1,12),
|
||||
sex= 1, # slut
|
||||
birthday_d= random.randint(1, 28),
|
||||
birthday_m= random.randint(1, 12),
|
||||
birthday_y= random.randint(1975, 1990),
|
||||
zipcode= 75001,
|
||||
country= 'fr',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ProfilesWalker(Optimization):
|
|||
|
||||
def start(self):
|
||||
self.walk_cron = self.sched.repeat(60, self.enqueue_profiles)
|
||||
self.view_cron = self.sched.schedule(randint(10,40), self.view_profile)
|
||||
self.view_cron = self.sched.schedule(randint(10, 40), self.view_profile)
|
||||
return True
|
||||
|
||||
def stop(self):
|
||||
|
|
@ -77,7 +77,7 @@ class ProfilesWalker(Optimization):
|
|||
try:
|
||||
id = self.profiles_queue.pop()
|
||||
except KeyError:
|
||||
return # empty queue
|
||||
return # empty queue
|
||||
|
||||
try:
|
||||
with self.browser:
|
||||
|
|
@ -101,4 +101,4 @@ class ProfilesWalker(Optimization):
|
|||
print e
|
||||
finally:
|
||||
if self.view_cron is not None:
|
||||
self.view_cron = self.sched.schedule(randint(10,40), self.view_profile)
|
||||
self.view_cron = self.sched.schedule(randint(10, 40), self.view_profile)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ from weboob.tools.test import BackendTest
|
|||
from weboob.tools.browser import BrowserUnavailable
|
||||
|
||||
|
||||
|
||||
__all__ = ['AuMTest']
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue