Fix flake8 warnings
This commit is contained in:
		
							parent
							
								
									1a5441ba75
								
							
						
					
					
						commit
						c5289f39bb
					
				
					 9 changed files with 37 additions and 31 deletions
				
			
		|  | @ -72,11 +72,11 @@ class Entry(models.Model, bsoup.SoupModelMixin): | |||
| 
 | ||||
|         # Ping Technorati | ||||
|         j = xmlrpc.client.Server('http://rpc.technorati.com/rpc/ping') | ||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url) | ||||
|         j.weblogUpdates.ping(blog_name, blog_url) | ||||
| 
 | ||||
|         # Ping Google Blog Search | ||||
|         j = xmlrpc.client.Server('http://blogsearch.google.com/ping/RPC2') | ||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||
|         j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||
| 
 | ||||
|         # Call any superclass's method | ||||
|         super().save() | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ from functools import reduce | |||
| 
 | ||||
| from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | ||||
| from django.shortcuts import get_object_or_404, render | ||||
| from django.views.generic import ListView | ||||
| from django.views.generic.dates import ( | ||||
|     DateDetailView, | ||||
|     DayArchiveView, | ||||
|  | @ -12,7 +11,7 @@ from django.views.generic.dates import ( | |||
| ) | ||||
| 
 | ||||
| from ..staff.models import Person | ||||
| from .models import Entry, EntryTag | ||||
| from .models import EntryTag | ||||
| 
 | ||||
| 
 | ||||
| def OR_filter(field_name, objs): | ||||
|  |  | |||
|  | @ -46,10 +46,12 @@ def run(cmd, encoding=None, ok_exitcodes=frozenset([0]), **kwargs): | |||
|         no_data = '' | ||||
|     with contextlib.ExitStack() as exit_stack: | ||||
|         proc = exit_stack.enter_context(subprocess.Popen(cmd, **kwargs)) | ||||
|         pipes = [exit_stack.enter_context(open( | ||||
|         pipes = [ | ||||
|             exit_stack.enter_context(open( | ||||
|                 getattr(proc, name).fileno(), mode, encoding=encoding, closefd=False)) | ||||
|             for name in ['stdout', 'stderr'] | ||||
|                  if kwargs.get(name) is subprocess.PIPE] | ||||
|             if kwargs.get(name) is subprocess.PIPE | ||||
|         ] | ||||
|         if pipes: | ||||
|             yield (proc, *pipes) | ||||
|         else: | ||||
|  | @ -88,6 +90,7 @@ class GitPath: | |||
| 
 | ||||
|     def _cache(orig_func): | ||||
|         attr_name = '_cached_' + orig_func.__name__ | ||||
| 
 | ||||
|         @functools.wraps(orig_func) | ||||
|         def cache_wrapper(self): | ||||
|             try: | ||||
|  |  | |||
|  | @ -13,9 +13,11 @@ from .news.models import PressRelease | |||
| 
 | ||||
| 
 | ||||
| class ConservancyFeedBase(Feed): | ||||
|     def copyright_holder(self): return "Software Freedom Conservancy" | ||||
|     def copyright_holder(self): | ||||
|         return "Software Freedom Conservancy" | ||||
| 
 | ||||
|     def license_no_html(self): return "Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License." | ||||
|     def license_no_html(self): | ||||
|         return "Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License." | ||||
| 
 | ||||
|     def item_copyright(self, item): | ||||
|         year = 2008 | ||||
|  | @ -89,7 +91,8 @@ class OmnibusFeed(ConservancyFeedBase): | |||
|     def item_description(self, item): | ||||
|         return item.summary | ||||
| 
 | ||||
|     def item_enclosure_mime_type(self): return "audio/mpeg" | ||||
|     def item_enclosure_mime_type(self): | ||||
|         return "audio/mpeg" | ||||
| 
 | ||||
|     def item_enclosure_url(self, item): | ||||
|         if hasattr(item, 'mp3_path'): | ||||
|  | @ -98,9 +101,6 @@ class OmnibusFeed(ConservancyFeedBase): | |||
|         if hasattr(item, 'mp3_path'): | ||||
|             return item.mp3_length | ||||
| 
 | ||||
|     def item_pubdate(self, item): | ||||
|         return item.pub_date | ||||
| 
 | ||||
|     def item_author_name(self, item): | ||||
|         if item.omnibus_type == "blog": | ||||
|             return item.author.formal_name | ||||
|  | @ -174,7 +174,8 @@ class BlogFeed(ConservancyFeedBase): | |||
|             firstTime = True | ||||
|             done = {} | ||||
|             for tag in tags: | ||||
|                 if tag in done: continue | ||||
|                 if tag in done: | ||||
|                     continue | ||||
|                 if firstTime: | ||||
|                     answer += " (" | ||||
|                     firstTime = False | ||||
|  | @ -192,8 +193,10 @@ class BlogFeed(ConservancyFeedBase): | |||
| 
 | ||||
|         GET = obj.GET | ||||
|         tags = [] | ||||
|         if 'author' in GET: tags = GET.getlist('author') | ||||
|         if 'tag' in GET:    tags += GET.getlist('tag') | ||||
|         if 'author' in GET: | ||||
|             tags = GET.getlist('author') | ||||
|         if 'tag' in GET: | ||||
|             tags += GET.getlist('tag') | ||||
| 
 | ||||
|         done = {} | ||||
|         if len(tags) == 1: | ||||
|  | @ -201,7 +204,8 @@ class BlogFeed(ConservancyFeedBase): | |||
|         elif len(tags) > 1: | ||||
|             firstTime = True | ||||
|             for tag in tags: | ||||
|                 if tag in done: continue | ||||
|                 if tag in done: | ||||
|                     continue | ||||
|                 if firstTime: | ||||
|                     answer += " tagged with " | ||||
|                     firstTime = False | ||||
|  |  | |||
|  | @ -34,8 +34,10 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | |||
|         return self.headline | ||||
| 
 | ||||
|     def get_absolute_url(self): | ||||
|         return "/news/{}/{}/".format(self.pub_date.strftime("%Y/%b/%d").lower(), | ||||
|                                   self.slug) | ||||
|         return "/news/{}/{}/".format( | ||||
|             self.pub_date.strftime("%Y/%b/%d").lower(), | ||||
|             self.slug, | ||||
|         ) | ||||
| 
 | ||||
|     def is_recent(self): | ||||
|         return self.pub_date > (datetime.now() - timedelta(days=5)) | ||||
|  | @ -60,11 +62,11 @@ class PressRelease(models.Model, bsoup.SoupModelMixin): | |||
| 
 | ||||
|         # Ping Technorati | ||||
|         j = xmlrpc.client.Server('http://rpc.technorati.com/rpc/ping') | ||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url) | ||||
|         j.weblogUpdates.ping(blog_name, blog_url) | ||||
| 
 | ||||
|         # Ping Google Blog Search | ||||
|         j = xmlrpc.client.Server('http://blogsearch.google.com/ping/RPC2') | ||||
|         reply = j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||
|         j.weblogUpdates.ping(blog_name, blog_url, post_url) | ||||
| 
 | ||||
|         # Call any superclass's method | ||||
|         super().save() | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| from datetime import datetime | ||||
| 
 | ||||
| from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator | ||||
| from django.http import HttpResponse | ||||
| from django.shortcuts import render | ||||
| from django.views.generic import ListView | ||||
| from django.views.generic.dates import ( | ||||
|  | @ -11,8 +10,7 @@ from django.views.generic.dates import ( | |||
|     YearArchiveView, | ||||
| ) | ||||
| 
 | ||||
| from ..events.models import Event | ||||
| from .models import ExternalArticle, PressRelease | ||||
| from .models import PressRelease | ||||
| 
 | ||||
| 
 | ||||
| class NewsListView(ListView): | ||||
|  | @ -27,8 +25,9 @@ def listing(request, *args, **kwargs): | |||
|     news_queryset = PressRelease.objects.all() | ||||
| 
 | ||||
| #    if (not kwargs.has_key('allow_future')) or not kwargs['allow_future']: | ||||
|     news_queryset = news_queryset.filter(**{'%s__lte' % kwargs['date_field']: | ||||
|                           datetime.now()}) | ||||
|     news_queryset = news_queryset.filter( | ||||
|         **{'%s__lte' % kwargs['date_field']: datetime.now()} | ||||
|     ) | ||||
| 
 | ||||
|     date_list = news_queryset.dates(kwargs['date_field'], 'year') | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,7 +19,6 @@ | |||
| from datetime import datetime, timedelta | ||||
| 
 | ||||
| from django.db import models | ||||
| from django.urls import reverse | ||||
| 
 | ||||
| 
 | ||||
| class Podcast(models.Model): | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| from .base import * | ||||
| from .base import *  # NOQA | ||||
| 
 | ||||
| DEBUG = True | ||||
| ALLOWED_HOSTS = ['*'] | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import json | |||
| 
 | ||||
| from django.core.exceptions import ImproperlyConfigured | ||||
| 
 | ||||
| from .base import * | ||||
| from .base import *  # NOQA | ||||
| 
 | ||||
| DEBUG = False | ||||
| ALLOWED_HOSTS = ['www.sfconservancy.org', 'sfconservancy.org'] | ||||
|  | @ -25,7 +25,7 @@ DATABASES = { | |||
| 
 | ||||
| # Apache/mod_wsgi doesn't make it straightforward to pass environment variables | ||||
| # to Django (can't use the Apache config). | ||||
| with open(BASE_DIR.parent / 'secrets.json') as f: | ||||
| with open(BASE_DIR.parent / 'secrets.json') as f:  # NOQA | ||||
|     secrets = json.load(f) | ||||
| 
 | ||||
| def get_secret(secrets, setting): | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue