From 2f5f0dc864a1c4d8abeac09bde38c3ff2759f22a Mon Sep 17 00:00:00 2001 From: j Date: Thu, 13 Oct 2016 15:14:52 +0200 Subject: [PATCH] use __str__ no need for u'' anymore --- oxdata/lookup/models.py | 8 ++++---- oxdata/movie/models.py | 10 +++++----- oxdata/oxdjango/api/actions.py | 2 +- oxdata/oxdjango/shortcuts.py | 2 +- oxdata/poster/models.py | 4 ++-- oxdata/settings.py | 22 +++++++++++----------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/oxdata/lookup/models.py b/oxdata/lookup/models.py index 461d481..eac406c 100644 --- a/oxdata/lookup/models.py +++ b/oxdata/lookup/models.py @@ -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')) diff --git a/oxdata/movie/models.py b/oxdata/movie/models.py index dc45049..df6b50a 100644 --- a/oxdata/movie/models.py +++ b/oxdata/movie/models.py @@ -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): diff --git a/oxdata/oxdjango/api/actions.py b/oxdata/oxdjango/api/actions.py index 9701459..584f96b 100644 --- a/oxdata/oxdjango/api/actions.py +++ b/oxdata/oxdjango/api/actions.py @@ -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): diff --git a/oxdata/oxdjango/shortcuts.py b/oxdata/oxdjango/shortcuts.py index ab12434..b0f70be 100644 --- a/oxdata/oxdjango/shortcuts.py +++ b/oxdata/oxdjango/shortcuts.py @@ -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 diff --git a/oxdata/poster/models.py b/oxdata/poster/models.py index 2a76fa8..accda1f 100644 --- a/oxdata/poster/models.py +++ b/oxdata/poster/models.py @@ -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: diff --git a/oxdata/settings.py b/oxdata/settings.py index a8c9776..52d0010 100644 --- a/oxdata/settings.py +++ b/oxdata/settings.py @@ -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