use __str__ no need for u'' anymore
This commit is contained in:
parent
a569629373
commit
2f5f0dc864
6 changed files with 24 additions and 24 deletions
|
@ -63,11 +63,11 @@ class MovieId(models.Model):
|
|||
|
||||
#movieposterdb can be mapped via imdbid and does not need to be saved here
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
id = self.imdb_id
|
||||
if not id:
|
||||
id = self.id
|
||||
return u'%s (%s)' % (self.title, id)
|
||||
return '%s (%s)' % (self.title, id)
|
||||
|
||||
def updateFromWikipedia(self):
|
||||
if self.wikipedia_id:
|
||||
|
@ -91,7 +91,7 @@ class MovieId(models.Model):
|
|||
}.get(key, key), data.get(key, ''))
|
||||
|
||||
directors = data.get('director', [])
|
||||
self.director = u', '.join(directors)
|
||||
self.director = ', '.join(directors)
|
||||
if not self.wikipedia_id:
|
||||
self.wikipedia_id = ox.web.wikipedia.get_id(ox.web.wikipedia.get_url(imdb=self.imdb_id))
|
||||
if not self.wikipedia_id:
|
||||
|
@ -168,7 +168,7 @@ class MovieId(models.Model):
|
|||
'source': 'Internet Archive',
|
||||
'url': ox.web.archive.get_url(self.archiveorg_id).replace('http://', 'https://')
|
||||
})
|
||||
qs = u'"%s (%s)"'%(self.title, self.year)
|
||||
qs = '"%s (%s)"' % (self.title, self.year)
|
||||
links.append({
|
||||
'source': 'Google',
|
||||
'url': 'https://google.com/search?q=%s' % quote(qs.encode('utf-8'))
|
||||
|
|
|
@ -45,7 +45,7 @@ def find(info, guess=True):
|
|||
fkey = key
|
||||
if isinstance(info[key], list):
|
||||
fkey = '%s__iexact'%key
|
||||
value = normalize_value(u'\n'.join(info[key]) + '\n')
|
||||
value = normalize_value('\n'.join(info[key]) + '\n')
|
||||
else:
|
||||
value = normalize_value(info[key])
|
||||
q = q.filter(**{fkey:value})
|
||||
|
@ -83,8 +83,8 @@ class Imdb(models.Model):
|
|||
invalid = models.BooleanField(default=False)
|
||||
patch = DictField(default=None, blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] %s%s" % (self.imdb, self.title, self.year and ' (%s)' % self.year or '')
|
||||
def __str__(self):
|
||||
return "[%s] %s%s" % (self.imdb, self.title, self.year and ' (%s)' % self.year or '')
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(Imdb, self).save(*args, **kwargs)
|
||||
|
@ -120,7 +120,7 @@ class Imdb(models.Model):
|
|||
if key in info:
|
||||
value = info[key]
|
||||
if isinstance(value, list):
|
||||
value = u'\n'.join(value) + '\n'
|
||||
value = '\n'.join(value) + '\n'
|
||||
if isinstance(value, string_types):
|
||||
value = normalize_value(value)
|
||||
setattr(self, key, value)
|
||||
|
@ -285,7 +285,7 @@ class Match(models.Model):
|
|||
key = models.CharField(max_length=28, db_index=True)
|
||||
item = models.ForeignKey(Imdb, related_name='matches')
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return '%s(%s)' % (self.hexdigest(), self.item.imdb)
|
||||
|
||||
def json(self):
|
||||
|
|
|
@ -110,7 +110,7 @@ class ApiActions(dict):
|
|||
fc = filter(lambda c: hasattr(c.cell_contents, '__call__'), f.func_closure)
|
||||
f = fc[len(fc)-1].cell_contents
|
||||
info = f.func_code.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||
info = u'%s:%s' % (info, f.func_code.co_firstlineno)
|
||||
info = '%s:%s' % (info, f.func_code.co_firstlineno)
|
||||
return info, trim(inspect.getsource(f))
|
||||
|
||||
def register(self, method, action=None, cache=True, version=None):
|
||||
|
|
|
@ -24,7 +24,7 @@ def _to_json(python_object):
|
|||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
if isinstance(python_object, datetime_safe.datetime):
|
||||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
raise TypeError(u'%s %s is not JSON serializable' % (repr(python_object), type(python_object)))
|
||||
raise TypeError('%s %s is not JSON serializable' % (repr(python_object), type(python_object)))
|
||||
|
||||
def render_to_json_response(dictionary, content_type="text/json", status=200):
|
||||
indent = None
|
||||
|
|
|
@ -76,8 +76,8 @@ class PosterCache(models.Model):
|
|||
status = models.CharField(max_length=1024, default='200')
|
||||
failed = models.BooleanField(default=False)
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s' % self.url
|
||||
def __str__(self):
|
||||
return '%s' % self.url
|
||||
|
||||
def get(self):
|
||||
if not self.image and not self.failed:
|
||||
|
|
|
@ -147,17 +147,17 @@ BROKER_URL = 'amqp://oxdata:ox@localhost:5672//odata'
|
|||
|
||||
#Movie related settings
|
||||
REVIEW_WHITELIST = {
|
||||
u'.filmcritic.com': u'Filmcritic',
|
||||
u'metacritic.com': u'Metacritic',
|
||||
u'nytimes.com': u'New York Times',
|
||||
u'rottentomatoes.com': u'Rotten Tomatoes',
|
||||
u'salon.com': u'Salon.com',
|
||||
u'sensesofcinema.com': u'Senses of Cinema',
|
||||
u'villagevoice.com': u'Village Voice',
|
||||
u'washingtonpost.com': u'Washington Post',
|
||||
u'rogerebert.suntimes.com': u'Chicago Sun-Times',
|
||||
u'sfgate.com': u'San Francisco Chronicle',
|
||||
u'rollingstone.com': u'Rolling Stone'
|
||||
'.filmcritic.com': 'Filmcritic',
|
||||
'metacritic.com': 'Metacritic',
|
||||
'nytimes.com': 'New York Times',
|
||||
'rottentomatoes.com': 'Rotten Tomatoes',
|
||||
'salon.com': 'Salon.com',
|
||||
'sensesofcinema.com': 'Senses of Cinema',
|
||||
'villagevoice.com': 'Village Voice',
|
||||
'washingtonpost.com': 'Washington Post',
|
||||
'rogerebert.suntimes.com': 'Chicago Sun-Times',
|
||||
'sfgate.com': 'San Francisco Chronicle',
|
||||
'rollingstone.com': 'Rolling Stone'
|
||||
}
|
||||
|
||||
#overwrite default settings with local settings
|
||||
|
|
Loading…
Reference in a new issue