Code style fixes
autopep8 -ir -j2 --select=W601,W602 . Diff checked manually.
This commit is contained in:
parent
f0abb61123
commit
75b428af07
2 changed files with 15 additions and 15 deletions
|
|
@ -48,7 +48,7 @@ class ImdbBrowser(BaseBrowser):
|
||||||
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s' % pattern.encode('utf-8'))
|
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s' % pattern.encode('utf-8'))
|
||||||
jres = json.loads(res)
|
jres = json.loads(res)
|
||||||
for cat in ['title_popular','title_exact','title_approx']:
|
for cat in ['title_popular','title_exact','title_approx']:
|
||||||
if jres.has_key(cat):
|
if cat in jres:
|
||||||
for m in jres[cat]:
|
for m in jres[cat]:
|
||||||
tdesc = unicode(m['title_description'])
|
tdesc = unicode(m['title_description'])
|
||||||
if '<a' in tdesc and '>' in tdesc:
|
if '<a' in tdesc and '>' in tdesc:
|
||||||
|
|
@ -72,7 +72,7 @@ class ImdbBrowser(BaseBrowser):
|
||||||
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=%s' % pattern.encode('utf-8'))
|
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=%s' % pattern.encode('utf-8'))
|
||||||
jres = json.loads(res)
|
jres = json.loads(res)
|
||||||
for cat in ['name_popular','name_exact','name_approx']:
|
for cat in ['name_popular','name_exact','name_approx']:
|
||||||
if jres.has_key(cat):
|
if cat in jres:
|
||||||
for p in jres[cat]:
|
for p in jres[cat]:
|
||||||
person = Person(p['id'],latin2unicode(p['name']))
|
person = Person(p['id'],latin2unicode(p['name']))
|
||||||
person.real_name = NotLoaded
|
person.real_name = NotLoaded
|
||||||
|
|
@ -106,24 +106,24 @@ class ImdbBrowser(BaseBrowser):
|
||||||
other_titles = []
|
other_titles = []
|
||||||
roles = {}
|
roles = {}
|
||||||
|
|
||||||
if not jres.has_key('title'):
|
if 'title' not in jres:
|
||||||
return
|
return
|
||||||
title = htmlparser.unescape(unicode(jres['title'].strip()))
|
title = htmlparser.unescape(unicode(jres['title'].strip()))
|
||||||
if jres.has_key('poster'):
|
if 'poster' in jres:
|
||||||
thumbnail_url = unicode(jres['poster'])
|
thumbnail_url = unicode(jres['poster'])
|
||||||
if jres.has_key('directors'):
|
if 'directors' in jres:
|
||||||
short_description = unicode(', '.join(jres['directors']))
|
short_description = unicode(', '.join(jres['directors']))
|
||||||
if jres.has_key('runtime'):
|
if 'runtime' in jres:
|
||||||
dur_str = jres['runtime'][0].split(':')
|
dur_str = jres['runtime'][0].split(':')
|
||||||
if len(dur_str) == 1:
|
if len(dur_str) == 1:
|
||||||
duration = int(dur_str[0].split()[0])
|
duration = int(dur_str[0].split()[0])
|
||||||
else:
|
else:
|
||||||
duration = int(dur_str[1].split()[0])
|
duration = int(dur_str[1].split()[0])
|
||||||
if jres.has_key('also_known_as'):
|
if 'also_known_as' in jres:
|
||||||
for other_t in jres['also_known_as']:
|
for other_t in jres['also_known_as']:
|
||||||
if other_t.has_key('country') and other_t.has_key('title'):
|
if 'country' in other_t and 'title' in other_t:
|
||||||
other_titles.append('%s : %s' % (other_t['country'],htmlparser.unescape(other_t['title'])))
|
other_titles.append('%s : %s' % (other_t['country'],htmlparser.unescape(other_t['title'])))
|
||||||
if jres.has_key('release_date'):
|
if 'release_date' in jres:
|
||||||
dstr = str(jres['release_date'])
|
dstr = str(jres['release_date'])
|
||||||
year = int(dstr[:4])
|
year = int(dstr[:4])
|
||||||
if year == 0:
|
if year == 0:
|
||||||
|
|
@ -135,17 +135,17 @@ class ImdbBrowser(BaseBrowser):
|
||||||
if day == 0:
|
if day == 0:
|
||||||
day = 1
|
day = 1
|
||||||
release_date = datetime(year,month,day)
|
release_date = datetime(year,month,day)
|
||||||
if jres.has_key('country'):
|
if 'country' in jres:
|
||||||
country = u''
|
country = u''
|
||||||
for c in jres['country']:
|
for c in jres['country']:
|
||||||
country += '%s, '%c
|
country += '%s, '%c
|
||||||
country = country[:-2]
|
country = country[:-2]
|
||||||
if jres.has_key('plot_simple'):
|
if 'plot_simple' in jres:
|
||||||
pitch = unicode(jres['plot_simple'])
|
pitch = unicode(jres['plot_simple'])
|
||||||
if jres.has_key('rating') and jres.has_key('rating_count'):
|
if 'rating' in jres and 'rating_count' in jres:
|
||||||
note = u'%s/10 (%s votes)'%(jres['rating'],jres['rating_count'])
|
note = u'%s/10 (%s votes)'%(jres['rating'],jres['rating_count'])
|
||||||
for r in ['actor','director','writer']:
|
for r in ['actor','director','writer']:
|
||||||
if jres.has_key('%ss'%r):
|
if '%ss'%r in jres:
|
||||||
roles['%s'%r] = list(jres['%ss'%r])
|
roles['%s'%r] = list(jres['%ss'%r])
|
||||||
|
|
||||||
movie = Movie(id,title)
|
movie = Movie(id,title)
|
||||||
|
|
|
||||||
|
|
@ -364,8 +364,8 @@ class CapBaseObject(object):
|
||||||
if self._fields is not None and name in self._fields:
|
if self._fields is not None and name in self._fields:
|
||||||
return self._fields[name].value
|
return self._fields[name].value
|
||||||
else:
|
else:
|
||||||
raise AttributeError, "'%s' object has no attribute '%s'" % (
|
raise AttributeError("'%s' object has no attribute '%s'" % (
|
||||||
self.__class__.__name__, name)
|
self.__class__.__name__, name))
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue