From 967230bb620979d898ef90406cf5d83843c7e837 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Thu, 11 Apr 2013 21:20:29 +0200 Subject: [PATCH] much more pep8 --- mygpo/__init__.py | 1 - mygpo/admin/auth.py | 2 -- mygpo/api/__init__.py | 2 -- mygpo/api/advanced/__init__.py | 12 +++++++----- mygpo/api/advanced/directory.py | 1 - mygpo/api/advanced/settings.py | 5 ++--- mygpo/api/basic_auth.py | 1 - mygpo/api/constants.py | 1 - mygpo/api/exceptions.py | 1 - mygpo/api/httpresponse.py | 1 - mygpo/api/legacy.py | 1 - mygpo/api/management/commands/sanitizing-maintenance.py | 1 - mygpo/api/opml.py | 1 - mygpo/api/simple.py | 6 +++--- mygpo/core/models.py | 6 +++--- mygpo/core/tests.py | 1 - mygpo/data/feeddownloader.py | 2 +- mygpo/data/flickr.py | 1 - mygpo/data/management/commands/group-podcasts.py | 1 - mygpo/data/mimetype.py | 1 - mygpo/data/tests.py | 1 - mygpo/db/couchdb/episode.py | 2 +- mygpo/db/couchdb/episode_state.py | 4 ++-- mygpo/db/couchdb/management/commands/dump-sample.py | 8 +++++--- mygpo/db/couchdb/management/commands/sync-design-docs.py | 1 - .../management/commands/category-merge-spellings.py | 1 - mygpo/directory/tests.py | 1 - mygpo/directory/urls.py | 1 - mygpo/flattr.py | 2 +- mygpo/log.py | 1 - .../maintenance/management/commands/merge-duplicates.py | 1 - mygpo/maintenance/management/podcastcmd.py | 3 +-- mygpo/maintenance/merge.py | 11 ++++++----- mygpo/manage.py | 3 +-- mygpo/publisher/auth.py | 1 - mygpo/publisher/templatetags/pcharts.py | 6 +++--- mygpo/publisher/tests.py | 1 - mygpo/publisher/urls.py | 5 ++--- mygpo/publisher/views.py | 6 +++--- mygpo/settings.py | 7 +++---- mygpo/urls.py | 1 - mygpo/userfeeds/auth.py | 3 --- mygpo/userfeeds/tests.py | 1 - mygpo/userfeeds/views.py | 1 - mygpo/users/models.py | 7 ++++--- mygpo/users/ratings.py | 2 +- mygpo/utils.py | 10 ++++------ mygpo/web/templatetags/charts.py | 16 ++++++++-------- mygpo/web/templatetags/devices.py | 1 - mygpo/web/templatetags/episodes.py | 2 +- mygpo/web/templatetags/facebook.py | 2 +- mygpo/web/templatetags/flickr.py | 1 - mygpo/web/templatetags/googleanalytics.py | 1 - mygpo/web/templatetags/math.py | 2 -- mygpo/web/templatetags/menu.py | 1 - mygpo/web/templatetags/mygpoutil.py | 1 - mygpo/web/templatetags/utils.py | 2 +- mygpo/web/urls.py | 1 - mygpo/web/views/device.py | 7 +++---- mygpo/web/views/security.py | 1 - mygpo/web/views/settings.py | 14 +++++++------- mygpo/web/views/users.py | 2 +- 62 files changed, 75 insertions(+), 118 deletions(-) diff --git a/mygpo/__init__.py b/mygpo/__init__.py index 617b87b1..a932e20b 100644 --- a/mygpo/__init__.py +++ b/mygpo/__init__.py @@ -14,4 +14,3 @@ # You should have received a copy of the GNU Affero General Public License # along with my.gpodder.org. If not, see . # - diff --git a/mygpo/admin/auth.py b/mygpo/admin/auth.py index 0d1e280b..accef669 100644 --- a/mygpo/admin/auth.py +++ b/mygpo/admin/auth.py @@ -40,5 +40,3 @@ def require_staff(protected_view): raise Http404 return wrapper - - diff --git a/mygpo/api/__init__.py b/mygpo/api/__init__.py index cf69f1ad..a932e20b 100644 --- a/mygpo/api/__init__.py +++ b/mygpo/api/__init__.py @@ -14,5 +14,3 @@ # You should have received a copy of the GNU Affero General Public License # along with my.gpodder.org. If not, see . # - - diff --git a/mygpo/api/advanced/__init__.py b/mygpo/api/advanced/__init__.py index d8ece382..866416b0 100644 --- a/mygpo/api/advanced/__init__.py +++ b/mygpo/api/advanced/__init__.py @@ -83,7 +83,7 @@ def subscriptions(request, username, device_uid): return HttpResponseNotFound(str(e)) since_ = request.GET.get('since', None) - if since_ == None: + if since_ is None: return HttpResponseBadRequest('parameter since missing') try: since = datetime.fromtimestamp(float(since_)) @@ -329,11 +329,13 @@ def update_episodes(user, actions, now, ua_string): podcast_url = action['podcast'] podcast_url = sanitize_append(podcast_url, 'podcast', update_urls) - if podcast_url == '': continue + if podcast_url == '': + continue episode_url = action['episode'] episode_url = sanitize_append(episode_url, 'episode', update_urls) - if episode_url == '': continue + if episode_url == '': + continue act = parse_episode_action(action, user, update_urls, now, ua_string) grouped_actions[ (podcast_url, episode_url) ].append(act) @@ -423,7 +425,7 @@ def device(request, username, device_uid): if 'type' in data: if not valid_devicetype(data['type']): - return HttpResponseBadRequest('invalid device type %s' % data['type']) + return HttpResponseBadRequest('invalid device type %s' % data['type']) d.type = data['type'] @@ -503,7 +505,7 @@ class DeviceUpdates(View): return HttpResponseNotFound(str(e)) since_ = request.GET.get('since', None) - if since_ == None: + if since_ is None: return HttpResponseBadRequest('parameter since missing') try: since = datetime.fromtimestamp(float(since_)) diff --git a/mygpo/api/advanced/directory.py b/mygpo/api/advanced/directory.py index d55e8750..35032ec0 100644 --- a/mygpo/api/advanced/directory.py +++ b/mygpo/api/advanced/directory.py @@ -147,4 +147,3 @@ def category_data(category): tag = category.label, usage = category.get_weight() ) - diff --git a/mygpo/api/advanced/settings.py b/mygpo/api/advanced/settings.py index 6c1728f8..5d0fb1d1 100644 --- a/mygpo/api/advanced/settings.py +++ b/mygpo/api/advanced/settings.py @@ -66,8 +66,8 @@ def main(request, username, scope): return episode_state, episode_state models = dict( - account = lambda: user_settings (request.user), - device = lambda: device_settings (request.user, request.GET.get('device', '')), + account = lambda: user_settings(request.user), + device = lambda: device_settings(request.user, request.GET.get('device', '')), podcast = lambda: podcast_settings(request.user, request.GET.get('podcast', '')), episode = lambda: episode_settings(request.user, request.GET.get('episode', ''), request.GET.get('podcast', '')) ) @@ -100,4 +100,3 @@ def update_settings(obj, actions): del obj.settings[key] return obj.settings - diff --git a/mygpo/api/basic_auth.py b/mygpo/api/basic_auth.py index d169f6c0..7c662fc7 100644 --- a/mygpo/api/basic_auth.py +++ b/mygpo/api/basic_auth.py @@ -172,4 +172,3 @@ def has_perm_or_basicauth(perm, realm = ""): realm, *args, **kwargs) return wrapper return view_decorator - diff --git a/mygpo/api/constants.py b/mygpo/api/constants.py index 1b915678..cc6e9571 100644 --- a/mygpo/api/constants.py +++ b/mygpo/api/constants.py @@ -46,4 +46,3 @@ SUBSCRIPTION_ACTION_TYPES = ( (SUBSCRIBE_ACTION, _('subscribed')), (UNSUBSCRIBE_ACTION, _('unsubscribed')), ) - diff --git a/mygpo/api/exceptions.py b/mygpo/api/exceptions.py index aa1fa7c1..145763fb 100644 --- a/mygpo/api/exceptions.py +++ b/mygpo/api/exceptions.py @@ -5,4 +5,3 @@ class ParameterMissing(Exception): def __str__(self): return repr(self.value) - diff --git a/mygpo/api/httpresponse.py b/mygpo/api/httpresponse.py index a811a085..c67a00ae 100644 --- a/mygpo/api/httpresponse.py +++ b/mygpo/api/httpresponse.py @@ -34,4 +34,3 @@ class JsonResponse(HttpResponse): super(JsonResponse, self).__init__( content, content_type=content_type) - diff --git a/mygpo/api/legacy.py b/mygpo/api/legacy.py index 80b6eb61..c7404e25 100644 --- a/mygpo/api/legacy.py +++ b/mygpo/api/legacy.py @@ -125,4 +125,3 @@ def auth(emailaddr, password): return None return user - diff --git a/mygpo/api/management/commands/sanitizing-maintenance.py b/mygpo/api/management/commands/sanitizing-maintenance.py index f8a79b69..9cfca321 100644 --- a/mygpo/api/management/commands/sanitizing-maintenance.py +++ b/mygpo/api/management/commands/sanitizing-maintenance.py @@ -15,4 +15,3 @@ class Command(BaseCommand): def handle(self, *args, **options): maintenance(options.get('dry_run')) - diff --git a/mygpo/api/opml.py b/mygpo/api/opml.py index caf4a6e3..3b607669 100644 --- a/mygpo/api/opml.py +++ b/mygpo/api/opml.py @@ -113,4 +113,3 @@ class Exporter(object): return doc.toprettyxml(encoding='utf-8', \ indent=' ', \ newl=os.linesep) - diff --git a/mygpo/api/simple.py b/mygpo/api/simple.py index 01392f5b..f47ce7a0 100644 --- a/mygpo/api/simple.py +++ b/mygpo/api/simple.py @@ -264,9 +264,9 @@ def toplist(request, count, format): p = podcast_data(podcast, domain, scale) p.update(dict( - subscribers= podcast.subscriber_count(), - subscribers_last_week= podcast.prev_subscriber_count(), - position_last_week= podcast.old_pos, + subscribers = podcast.subscriber_count(), + subscribers_last_week = podcast.prev_subscriber_count(), + position_last_week = podcast.old_pos, )) return p diff --git a/mygpo/core/models.py b/mygpo/core/models.py index da377668..646d508b 100644 --- a/mygpo/core/models.py +++ b/mygpo/core/models.py @@ -104,7 +104,7 @@ class Episode(Document, SlugMixin, OldIdMixin): def __eq__(self, other): - if other == None: + if other is None: return False return self._id == other._id @@ -383,7 +383,7 @@ class Podcast(Document, SlugMixin, OldIdMixin): def save(self): group = getattr(self, 'group', None) - if group: #we are part of a PodcastGroup + if group: # we are part of a PodcastGroup group = PodcastGroup.get(group) podcasts = list(group.podcasts) @@ -426,7 +426,7 @@ class Podcast(Document, SlugMixin, OldIdMixin): if not self.get_id(): return self == other - if other == None: + if other is None: return False return self.get_id() == other.get_id() diff --git a/mygpo/core/tests.py b/mygpo/core/tests.py index 694e618c..1caa36e4 100644 --- a/mygpo/core/tests.py +++ b/mygpo/core/tests.py @@ -67,4 +67,3 @@ def suite(): suite.addTest(doctest.DocTestSuite(mygpo.utils)) suite.addTest(unittest.TestLoader().loadTestsFromTestCase(PodcastGroupTests)) return suite - diff --git a/mygpo/data/feeddownloader.py b/mygpo/data/feeddownloader.py index 3921d69c..2c9cc0a2 100755 --- a/mygpo/data/feeddownloader.py +++ b/mygpo/data/feeddownloader.py @@ -311,7 +311,7 @@ class PodcastUpdater(object): for f in thumbnails: os.unlink(f) - return cover_art + return cover_art except (urllib2.HTTPError, urllib2.URLError, ValueError, httplib.BadStatusLine) as e: diff --git a/mygpo/data/flickr.py b/mygpo/data/flickr.py index 0c3de645..2fde301a 100644 --- a/mygpo/data/flickr.py +++ b/mygpo/data/flickr.py @@ -57,4 +57,3 @@ def get_display_photo(url, label='Medium'): return s['source'] return url - diff --git a/mygpo/data/management/commands/group-podcasts.py b/mygpo/data/management/commands/group-podcasts.py index 4de89e38..974beb70 100644 --- a/mygpo/data/management/commands/group-podcasts.py +++ b/mygpo/data/management/commands/group-podcasts.py @@ -21,4 +21,3 @@ class Command(BaseCommand): p2 = podcast_for_url(p2_url) p1.group_with(p2, group_title, myname, othername) - diff --git a/mygpo/data/mimetype.py b/mygpo/data/mimetype.py index 0ca5e53d..5aac0854 100644 --- a/mygpo/data/mimetype.py +++ b/mygpo/data/mimetype.py @@ -64,4 +64,3 @@ def get_mimetype(mimetype, url): mimetype, _encoding = mimetypes.guess_type(url) return mimetype - diff --git a/mygpo/data/tests.py b/mygpo/data/tests.py index b10a3a02..a69c7c56 100644 --- a/mygpo/data/tests.py +++ b/mygpo/data/tests.py @@ -24,4 +24,3 @@ from django.test import TestCase def suite(): suite = unittest.TestSuite() return suite - diff --git a/mygpo/db/couchdb/episode.py b/mygpo/db/couchdb/episode.py index 673a4f10..e7b92ffd 100644 --- a/mygpo/db/couchdb/episode.py +++ b/mygpo/db/couchdb/episode.py @@ -151,7 +151,7 @@ def episode_for_podcast_url(podcast_url, episode_url, create=False): podcast = podcast_for_url(podcast_url, create=create) - if not podcast: # podcast does not exist and should not be created + if not podcast: # podcast does not exist and should not be created return None return episode_for_podcast_id_url(podcast.get_id(), episode_url, create) diff --git a/mygpo/db/couchdb/episode_state.py b/mygpo/db/couchdb/episode_state.py index ad9a7f58..549b2034 100644 --- a/mygpo/db/couchdb/episode_state.py +++ b/mygpo/db/couchdb/episode_state.py @@ -61,7 +61,7 @@ def all_episode_states(episode): if not episode: raise QueryParameterMissing('episode') - r = EpisodeUserState.view('episode_states/by_podcast_episode', + r = EpisodeUserState.view('episode_states/by_podcast_episode', startkey = [episode.podcast, episode._id, None], endkey = [episode.podcast, episode._id, {}], include_docs = True, @@ -75,7 +75,7 @@ def all_podcast_episode_states(podcast): if not podcast: raise QueryParameterMissing('podcast') - r = EpisodeUserState.view('episode_states/by_podcast_episode', + r = EpisodeUserState.view('episode_states/by_podcast_episode', startkey = [podcast.get_id(), None, None], endkey = [podcast.get_id(), {}, {}], include_docs = True diff --git a/mygpo/db/couchdb/management/commands/dump-sample.py b/mygpo/db/couchdb/management/commands/dump-sample.py index 0c28fc43..74f95411 100755 --- a/mygpo/db/couchdb/management/commands/dump-sample.py +++ b/mygpo/db/couchdb/management/commands/dump-sample.py @@ -88,7 +88,8 @@ class Command(BaseCommand): # Categories for tag in p_state.tags: c = category_for_tag(tag) - if c: docs.add(c._id) + if c: + docs.add(c._id) # Podcast podcast = podcast_by_id(p_state.podcast) @@ -110,7 +111,8 @@ class Command(BaseCommand): for s in podcast.tags: for tag in podcast.tags[s]: c = category_for_tag(tag) - if c: docs.add(c._id) + if c: + docs.add(c._id) # Episodes for episode in episodes_for_podcast(podcast.get_podcast()): @@ -152,7 +154,7 @@ class Command(BaseCommand): for name, info in attachments.items(): content_type = info.get('content_type') - if content_type is None: # CouchDB < 0.8 + if content_type is None: # CouchDB < 0.8 content_type = info.get('content-type') parts.add(content_type, b64decode(info['data']), { 'Content-ID': name diff --git a/mygpo/db/couchdb/management/commands/sync-design-docs.py b/mygpo/db/couchdb/management/commands/sync-design-docs.py index 171fe9f6..fabc8df0 100755 --- a/mygpo/db/couchdb/management/commands/sync-design-docs.py +++ b/mygpo/db/couchdb/management/commands/sync-design-docs.py @@ -17,4 +17,3 @@ class Command(BaseCommand): db = get_main_database() loader = FileSystemDocsLoader(path) loader.sync(db, verbose=True) - diff --git a/mygpo/directory/management/commands/category-merge-spellings.py b/mygpo/directory/management/commands/category-merge-spellings.py index 8d5a1e37..52dfadb0 100644 --- a/mygpo/directory/management/commands/category-merge-spellings.py +++ b/mygpo/directory/management/commands/category-merge-spellings.py @@ -55,4 +55,3 @@ Usage: category.updated = start_time category.save() - diff --git a/mygpo/directory/tests.py b/mygpo/directory/tests.py index b10a3a02..a69c7c56 100644 --- a/mygpo/directory/tests.py +++ b/mygpo/directory/tests.py @@ -24,4 +24,3 @@ from django.test import TestCase def suite(): suite = unittest.TestSuite() return suite - diff --git a/mygpo/directory/urls.py b/mygpo/directory/urls.py index f6bbcd03..40944fe6 100644 --- a/mygpo/directory/urls.py +++ b/mygpo/directory/urls.py @@ -35,4 +35,3 @@ urlpatterns = patterns('mygpo.directory.views', url(r'^search/$', 'search', name='search'), url(r'^lists/$', 'podcast_lists', name='podcast-lists'), ) - diff --git a/mygpo/flattr.py b/mygpo/flattr.py index e5bf3f77..03b13c0b 100644 --- a/mygpo/flattr.py +++ b/mygpo/flattr.py @@ -179,7 +179,7 @@ class Flattr(object): args = [(u'url', self.domain + thing.url)] args += [(arg, getattr(thing, arg, None)) for arg in optional_args] - args = filter(lambda (k, v): v, args) # filter out empty arguments + args = filter(lambda (k, v): v, args) # filter out empty arguments # TODO: check encoding args = [(k, v.encode('utf-8')) for (k, v) in args] diff --git a/mygpo/log.py b/mygpo/log.py index 6aea1f68..befa43cf 100644 --- a/mygpo/log.py +++ b/mygpo/log.py @@ -23,4 +23,3 @@ syslog.openlog('my.gpodder.org') def log(message): syslog.syslog(message) - diff --git a/mygpo/maintenance/management/commands/merge-duplicates.py b/mygpo/maintenance/management/commands/merge-duplicates.py index ec8587ea..02f312e5 100755 --- a/mygpo/maintenance/management/commands/merge-duplicates.py +++ b/mygpo/maintenance/management/commands/merge-duplicates.py @@ -30,4 +30,3 @@ class Command(BaseCommand): merge.merge_objects(podcasts=podcasts, podcast_states=podcast_states, episodes=episodes, episode_states=episode_states, dry_run=dry_run) - diff --git a/mygpo/maintenance/management/podcastcmd.py b/mygpo/maintenance/management/podcastcmd.py index f197fea5..9b7e0997 100644 --- a/mygpo/maintenance/management/podcastcmd.py +++ b/mygpo/maintenance/management/podcastcmd.py @@ -51,7 +51,7 @@ class PodcastCommand(BaseCommand): if not args and not options.get('toplist') and not options.get('new') \ and not options.get('random'): - yield (p.url for p in podcasts_by_last_update()) + yield (p.url for p in podcasts_by_last_update()) def get_toplist(self): @@ -62,4 +62,3 @@ class PodcastCommand(BaseCommand): elif isinstance(obj, PodcastGroup): for p in obj.podcasts: yield p - diff --git a/mygpo/maintenance/merge.py b/mygpo/maintenance/merge.py index 960b3684..8fa78658 100644 --- a/mygpo/maintenance/merge.py +++ b/mygpo/maintenance/merge.py @@ -227,7 +227,8 @@ class PodcastMerger(object): for a, b in utils.iterate_together( [podcast1.subscribers, podcast2.subscribers], key): - if a is None or b is None: continue + if a is None or b is None: + continue # avoid increasing subscriber_count when merging # duplicate entries of a single podcast @@ -290,12 +291,12 @@ class PodcastMerger(object): if state == state2: continue - if state == None: + if state is None: self.actions['move-podcast-state'] += 1 self._move_state(state2=state2, new_id=podcast1.get_id(), new_url=podcast1.url) - elif state2 == None: + elif state2 is None: continue else: @@ -375,12 +376,12 @@ class EpisodeMerger(object): if state == state2: continue - if state == None: + if state is None: self.actions['move-episode-state'] += 1 self._move(state2=state2, podcast_id=self.episode1.podcast, episode_id=self.episode1._id) - elif state2 == None: + elif state2 is None: continue else: diff --git a/mygpo/manage.py b/mygpo/manage.py index dbbf7c8f..0101c54d 100755 --- a/mygpo/manage.py +++ b/mygpo/manage.py @@ -27,11 +27,10 @@ sys.path.insert(0, updir) from django.core.management import execute_manager try: - import settings # Assumed to be in the same directory. + import settings # Assumed to be in the same directory. except ImportError: sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) sys.exit(1) if __name__ == "__main__": execute_manager(settings) - diff --git a/mygpo/publisher/auth.py b/mygpo/publisher/auth.py index 127bd79a..b11065ad 100644 --- a/mygpo/publisher/auth.py +++ b/mygpo/publisher/auth.py @@ -52,4 +52,3 @@ def is_publisher(user): return True return False - diff --git a/mygpo/publisher/templatetags/pcharts.py b/mygpo/publisher/templatetags/pcharts.py index 8cfd9d35..ee45d6b1 100644 --- a/mygpo/publisher/templatetags/pcharts.py +++ b/mygpo/publisher/templatetags/pcharts.py @@ -18,10 +18,10 @@ def bar_chart(parts): 'chs=%dx100' % width, 'chl=%s' % '|'.join([x['x'] for x in parts]), 'chd=t:%s' % ','.join([ repr(int(x['y'])) for x in parts ]), - 'chxt=x,y', # visible axes + 'chxt=x,y', # visible axes 'chbh=%d,%d,%d' % (bar_width, bar_space, group_space), - 'chds=0,%d' % maxv, # avis scaling from 0 to max - 'chxr=1,0,%d' % maxv, # labeling for axis 1 (y) from 0 to max + 'chds=0,%d' % maxv, # avis scaling from 0 to max + 'chxr=1,0,%d' % maxv, # labeling for axis 1 (y) from 0 to max ] s = '' % '&'.join(parts) diff --git a/mygpo/publisher/tests.py b/mygpo/publisher/tests.py index 7cb61222..97149746 100644 --- a/mygpo/publisher/tests.py +++ b/mygpo/publisher/tests.py @@ -27,4 +27,3 @@ def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(mygpo.publisher.utils)) return suite - diff --git a/mygpo/publisher/urls.py b/mygpo/publisher/urls.py index d260d2ab..9bcf200a 100644 --- a/mygpo/publisher/urls.py +++ b/mygpo/publisher/urls.py @@ -19,10 +19,10 @@ urlpatterns = patterns('mygpo.publisher.views', 'podcast_slug_id', name='podcast-publisher-detail-slug-id'), url(r'^podcast/(?P[\w-]+)/update$', - 'update_podcast_slug_id' , name='podcast-publisher-update-slug-id'), + 'update_podcast_slug_id', name='podcast-publisher-update-slug-id'), url(r'^podcast/(?P[\w-]+)/save$', - 'save_podcast_slug_id' , name='podcast-publisher-save-slug-id'), + 'save_podcast_slug_id', name='podcast-publisher-save-slug-id'), url(r'^podcast/(?P[\w-]+)/episodes$', 'episodes_slug_id', name='podcast-publisher-episodes-slug-id'), @@ -43,4 +43,3 @@ urlpatterns = patterns('mygpo.publisher.views', url(r'^link/$', 'link', name='link-here'), url(r'^advertise$', 'advertise', name='advertise'), ) - diff --git a/mygpo/publisher/views.py b/mygpo/publisher/views.py index 380baef2..22729acb 100644 --- a/mygpo/publisher/views.py +++ b/mygpo/publisher/views.py @@ -221,12 +221,12 @@ def episode(request, episode): return HttpResponseForbidden() if request.method == 'POST': - form = None #EpisodeForm(request.POST, instance=e) - #if form.is_valid(): + form = None # EpisodeForm(request.POST, instance=e) + # if form.is_valid(): # form.save() elif request.method == 'GET': - form = None #EpisodeForm(instance=e) + form = None # EpisodeForm(instance=e) timeline_data = list(episode_listener_data(episode)) diff --git a/mygpo/settings.py b/mygpo/settings.py index 6b825e7a..59fbc948 100644 --- a/mygpo/settings.py +++ b/mygpo/settings.py @@ -116,7 +116,7 @@ ROOT_URLCONF = 'mygpo.urls' TEMPLATE_DIRS = () INSTALLED_APPS = ( - 'django.contrib.contenttypes', # unused, but tests fail otherwise (?) + 'django.contrib.contenttypes', # unused, but tests fail otherwise (?) 'django.contrib.messages', 'django.contrib.humanize', 'couchdbkit.ext.django', @@ -237,6 +237,5 @@ GOOGLE_CLIENT_SECRET='' try: from settings_prod import * except ImportError, e: - import sys - print >> sys.stderr, 'create settings_prod.py with your customized settings' - + import sys + print >> sys.stderr, 'create settings_prod.py with your customized settings' diff --git a/mygpo/urls.py b/mygpo/urls.py index 21cdcbcb..258c592d 100644 --- a/mygpo/urls.py +++ b/mygpo/urls.py @@ -45,4 +45,3 @@ urlpatterns += patterns('', (r'^publisher/', include('mygpo.publisher.urls')), (r'^admin/', include('mygpo.admin.urls')), ) - diff --git a/mygpo/userfeeds/auth.py b/mygpo/userfeeds/auth.py index 83286235..55f6018b 100644 --- a/mygpo/userfeeds/auth.py +++ b/mygpo/userfeeds/auth.py @@ -96,6 +96,3 @@ def require_token_auth(token_name): **kwargs) return tmp return wrapper - - - diff --git a/mygpo/userfeeds/tests.py b/mygpo/userfeeds/tests.py index b10a3a02..a69c7c56 100644 --- a/mygpo/userfeeds/tests.py +++ b/mygpo/userfeeds/tests.py @@ -24,4 +24,3 @@ from django.test import TestCase def suite(): suite = unittest.TestSuite() return suite - diff --git a/mygpo/userfeeds/views.py b/mygpo/userfeeds/views.py index 4b7286c6..f6170ebb 100644 --- a/mygpo/userfeeds/views.py +++ b/mygpo/userfeeds/views.py @@ -23,4 +23,3 @@ def favorite_feed(request, username): 'feed_user': user, 'feed': feed, }, content_type='text/xml') - diff --git a/mygpo/users/models.py b/mygpo/users/models.py index 910bb011..fed743da 100644 --- a/mygpo/users/models.py +++ b/mygpo/users/models.py @@ -1,5 +1,6 @@ import re -import uuid, collections +import uuid +import collections from datetime import datetime import dateutil.parser from itertools import imap @@ -121,12 +122,12 @@ class EpisodeAction(DocumentSchema): # Sanity check: If started or total are given, require playmark if ((self.started is not None) or (self.total is not None)) and \ - self.playmark is None: + self.playmark is None: raise InvalidEpisodeActionAttributes('started and total require position') # Sanity check: total and playmark can only appear together if ((self.total is not None) or (self.started is not None)) and \ - ((self.total is None) or (self.started is None)): + ((self.total is None) or (self.started is None)): raise InvalidEpisodeActionAttributes('total and started can only appear together') diff --git a/mygpo/users/ratings.py b/mygpo/users/ratings.py index 1f429ed2..5ebfcda7 100644 --- a/mygpo/users/ratings.py +++ b/mygpo/users/ratings.py @@ -23,7 +23,7 @@ class RatingMixin(DocumentSchema): raise ValueError('Rating must be in %s' % (ALLOWED_RATINGS, )) rating = Rating(rating=rating_val, user=user_id) - self.ratings = filter(lambda r: r.user != None, self.ratings) + self.ratings = filter(lambda r: r.user is not None, self.ratings) self.ratings = filter(lambda r: r.user != user_id, self.ratings) self.ratings.append(rating) diff --git a/mygpo/utils.py b/mygpo/utils.py index 6ccd37fb..e36954d1 100644 --- a/mygpo/utils.py +++ b/mygpo/utils.py @@ -242,19 +242,17 @@ def first(it): returns the first not-None object or None if the iterator is exhausted """ for x in it: - if x != None: + if x is not None: return x return None def intersect(a, b): - return list(set(a) & set(b)) + return list(set(a) & set(b)) def remove_control_chars(s): - import unicodedata, re - all_chars = (unichr(i) for i in xrange(0x110000)) control_chars = ''.join(map(unichr, range(0,32) + range(127,160))) control_char_re = re.compile('[%s]' % re.escape(control_chars)) @@ -416,7 +414,7 @@ def longest_substr(strings): substr = "" if not strings: return substr - reference = shortest_of(strings) #strings[0] + reference = shortest_of(strings) length = len(reference) #find a suitable slice i:j for i in xrange(length): @@ -468,7 +466,7 @@ def file_hash(f, h=hashlib.md5, block_size=2**20): """ returns the hash of the contents of a file """ f_hash = h() for chunk in iter(lambda: f.read(block_size), ''): - f_hash.update(chunk) + f_hash.update(chunk) return f_hash diff --git a/mygpo/web/templatetags/charts.py b/mygpo/web/templatetags/charts.py index 49378817..d292f4e4 100644 --- a/mygpo/web/templatetags/charts.py +++ b/mygpo/web/templatetags/charts.py @@ -128,15 +128,15 @@ def episode_heatmap_visualization(heatmap): widths.append( end-start ) parts = [ - 'cht=bhs', #bar chart - 'chco=%s' % ','.join(part_colours), #colors - 'chs=%dx50' % WIDTH, #width corresponds to length, arbitrary height - 'chds=0,%s' % duration, #axis scaling from 0 to maximum duration + 'cht=bhs', # bar chart + 'chco=%s' % ','.join(part_colours), # colors + 'chs=%dx50' % WIDTH, # width corresponds to length, arbitrary height + 'chds=0,%s' % duration, # axis scaling from 0 to maximum duration 'chd=t:%s' % '|'.join([repr(w) for w in widths]), # all block have the same width - 'chxt=x', #visible axes - 'chxr=0,0,%s' % duration, #axis range for axis 0 (x): 0 - duration - 'chxl=0:|%s' % '|'.join(axis_label), #axis labels - 'chxp=0,%s' % ','.join([repr(x) for x in axis_pos]), #axis label positions + 'chxt=x', # visible axes + 'chxr=0,0,%s' % duration, # axis range for axis 0 (x): 0 - duration + 'chxl=0:|%s' % '|'.join(axis_label), # axis labels + 'chxp=0,%s' % ','.join([repr(x) for x in axis_pos]), # axis label positions ] s = '' % '&'.join(parts) diff --git a/mygpo/web/templatetags/devices.py b/mygpo/web/templatetags/devices.py index 5b6ba4e1..55dfe854 100644 --- a/mygpo/web/templatetags/devices.py +++ b/mygpo/web/templatetags/devices.py @@ -76,4 +76,3 @@ def device_link(device): name = device.name, icon = device_icon(device), ) - diff --git a/mygpo/web/templatetags/episodes.py b/mygpo/web/templatetags/episodes.py index 8aa73987..b7e97278 100644 --- a/mygpo/web/templatetags/episodes.py +++ b/mygpo/web/templatetags/episodes.py @@ -67,7 +67,7 @@ def episode_status_icon(action): elif action.action == 'delete': s = 'deleted' % ('%s%s%s' % (_('This episode has been deleted'),date_string, device_string)) else: - return action.action #this is not marked safe by intention + return action.action # this is not marked safe by intention return mark_safe(s) diff --git a/mygpo/web/templatetags/facebook.py b/mygpo/web/templatetags/facebook.py index c7270cfd..2b5e9e70 100644 --- a/mygpo/web/templatetags/facebook.py +++ b/mygpo/web/templatetags/facebook.py @@ -11,7 +11,7 @@ from mygpo.web.utils import get_episode_link_target, get_podcast_link_target register = template.Library() -LIKE_BUTTON_STR = """""" +LIKE_BUTTON_STR = """""" #FIXME: remove hardcoded URL # we could convert the filter to a tag once the takes_context diff --git a/mygpo/web/templatetags/flickr.py b/mygpo/web/templatetags/flickr.py index bcad7b61..dc2f47d0 100644 --- a/mygpo/web/templatetags/flickr.py +++ b/mygpo/web/templatetags/flickr.py @@ -15,4 +15,3 @@ def embed_flickr_photo(episode): img = flickr.get_display_photo(episode.url) s = '%s' % (episode.link, episode.title, img, episode.title) return mark_safe(s) - diff --git a/mygpo/web/templatetags/googleanalytics.py b/mygpo/web/templatetags/googleanalytics.py index 1ddfdbfa..5864dbfe 100644 --- a/mygpo/web/templatetags/googleanalytics.py +++ b/mygpo/web/templatetags/googleanalytics.py @@ -22,4 +22,3 @@ def google_analytics_async(property_id): """ % property_id return mark_safe(s) - diff --git a/mygpo/web/templatetags/math.py b/mygpo/web/templatetags/math.py index c1e88b81..7d66b0dc 100644 --- a/mygpo/web/templatetags/math.py +++ b/mygpo/web/templatetags/math.py @@ -6,5 +6,3 @@ register = template.Library() @register.filter def subtract(value, sub): return value - sub - - diff --git a/mygpo/web/templatetags/menu.py b/mygpo/web/templatetags/menu.py index cb016f55..02acae86 100644 --- a/mygpo/web/templatetags/menu.py +++ b/mygpo/web/templatetags/menu.py @@ -126,4 +126,3 @@ def section_menu(selected, title=None): s = '\n'.join(items) return mark_safe(s) - diff --git a/mygpo/web/templatetags/mygpoutil.py b/mygpo/web/templatetags/mygpoutil.py index 5ec1be23..ce1b532b 100644 --- a/mygpo/web/templatetags/mygpoutil.py +++ b/mygpo/web/templatetags/mygpoutil.py @@ -36,4 +36,3 @@ def remove_html_tags(html): result = re.sub('([\r\n]{2})([\r\n])+', '\\1', result) return mark_safe(result.strip()) - diff --git a/mygpo/web/templatetags/utils.py b/mygpo/web/templatetags/utils.py index d87c586e..84ce1073 100644 --- a/mygpo/web/templatetags/utils.py +++ b/mygpo/web/templatetags/utils.py @@ -66,5 +66,5 @@ def markdown(txt): def nbsp(s): """ collapses multiple whitespaces and replaces them with   """ import re - s = re.sub("\s+" , " ", s) + s = re.sub("\s+", " ", s) return mark_safe(s) diff --git a/mygpo/web/urls.py b/mygpo/web/urls.py index 828dbc2e..acd92333 100644 --- a/mygpo/web/urls.py +++ b/mygpo/web/urls.py @@ -185,4 +185,3 @@ urlpatterns += patterns('mygpo.web.views.users', (r'^activate/(?P\w+)$', activate, {'backend': 'django_couchdb_utils.registration.backends.default.DefaultBackend'}), ) - diff --git a/mygpo/web/views/device.py b/mygpo/web/views/device.py index 954b9757..c6307d81 100644 --- a/mygpo/web/views/device.py +++ b/mygpo/web/views/device.py @@ -157,7 +157,7 @@ def update(request, device): try: request.user.update_device(device) messages.success(request, _('Device updated')) - uid = device.uid # accept the new UID after rest has succeeded + uid = device.uid # accept the new UID after rest has succeeded except DeviceUIDException as e: messages.error(request, _(str(e))) @@ -180,7 +180,7 @@ def edit_new(request): device_form = DeviceForm({ 'name': device.name, 'type': device.type, - 'uid' : device.uid + 'uid': device.uid }) return render(request, 'device-create.html', { @@ -199,7 +199,7 @@ def edit(request, device): device_form = DeviceForm({ 'name': device.name, 'type': device.type, - 'uid' : device.uid + 'uid': device.uid }) synced_with = request.user.get_synced(device) @@ -361,4 +361,3 @@ def unsync(request, device): from mygpo.web import views history = views.history - diff --git a/mygpo/web/views/security.py b/mygpo/web/views/security.py index 5cb2042c..f192ded2 100644 --- a/mygpo/web/views/security.py +++ b/mygpo/web/views/security.py @@ -33,4 +33,3 @@ def csrf_failure(request, reason=""): 'get': request.GET, 'post': request.POST, }) - diff --git a/mygpo/web/views/settings.py b/mygpo/web/views/settings.py index 6afd2106..33a85969 100644 --- a/mygpo/web/views/settings.py +++ b/mygpo/web/views/settings.py @@ -55,28 +55,28 @@ def account(request): if request.method == 'GET': - site = RequestSite(request) - flattr = Flattr(request.user, site.domain, request.is_secure()) - userpage_token = request.user.get_token('userpage_token') + site = RequestSite(request) + flattr = Flattr(request.user, site.domain, request.is_secure()) + userpage_token = request.user.get_token('userpage_token') - profile_form = ProfileForm({ + profile_form = ProfileForm({ 'twitter': request.user.twitter, 'about': request.user.about, }) - form = UserAccountForm({ + form = UserAccountForm({ 'email': request.user.email, 'public': request.user.get_wksetting(PUBLIC_SUB_USER) }) - flattr_form = FlattrForm({ + flattr_form = FlattrForm({ 'enable': request.user.get_wksetting(FLATTR_AUTO), 'token': request.user.get_wksetting(FLATTR_TOKEN), 'flattr_mygpo': request.user.get_wksetting(FLATTR_MYGPO), 'username': request.user.get_wksetting(FLATTR_USERNAME), }) - return render(request, 'account.html', { + return render(request, 'account.html', { 'site': site, 'form': form, 'profile_form': profile_form, diff --git a/mygpo/web/views/users.py b/mygpo/web/views/users.py index 5d16689d..b097382a 100644 --- a/mygpo/web/views/users.py +++ b/mygpo/web/views/users.py @@ -196,7 +196,7 @@ def resend_activation(request): if user.deleted: raise ValueError(_('You have deleted your account, but you can regster again.')) - if user.activation_key == None: + if user.activation_key is None: _set_active(user=user, is_active=True) raise ValueError(_('Your account already has been activated. Go ahead and log in.')) -- 2.11.4.GIT