Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Wed, 01 May 2019 12:33:25 UTC Commit: a4b71fa5f4cf475407b064d45df3872305e242a6 https://github.com/geany/www.geany.org/commit/a4b71fa5f4cf475407b064d45df387...
Log Message: ----------- More Pep8 and Pylint cleanup
Modified Paths: -------------- geany/__init__.py geany/decorators.py geany/management/commands/dump_database.py geany/settings.py geany/sitemaps.py geany/templatetags/geany_tags.py geany/urls.py geany/urls_legacy.py latest_version/models.py latest_version/urls.py news/models.py news/urls.py news/views.py nightlybuilds/database_routers.py nightlybuilds/models.py nightlybuilds/templatetags/nightlybuilds_tags.py pastebin/api/create.py pastebin/forms.py pastebin/highlight.py pastebin/management/commands/generate_snippets_css.py pastebin/models.py pastebin/templatetags/pastebin_tags.py pastebin/urls.py pastebin/views.py static_docs/generate_i18n_statistics.py static_docs/github_client.py static_docs/urls.py static_docs/views.py
Modified: geany/__init__.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1,2 +1,2 @@
-default_app_config = 'geany.apps.GeanyAppConfig' +default_app_config = 'geany.apps.GeanyAppConfig' # pylint: disable=invalid-name
Modified: geany/decorators.py 20 lines changed, 11 insertions(+), 9 deletions(-) =================================================================== @@ -42,23 +42,25 @@ def myExpensiveMethod(parm1, parm2, parm3): .... return expensiveResult """ - def do_cache(f): - def x(*args, **kwargs): - key = '%s.%s' % ((f.__module__, f.__name__)) + def do_cache(function): + def wrapped(*args, **kwargs): + key = '%s.%s' % ((function.__module__, function.__name__)) if args and not ignore_arguments: cache_args = args # don't include 'self' in arguments - arguments = inspect.getargspec(f)[0] - if arguments and arguments[0] == 'self': + arguments = inspect.getfullargspec(function) + if arguments and arguments.args[0] == 'self': cache_args = args[1:] if cache_args: - key = '%s.args%s' % (key, hexlify(repr(cache_args))) + cache_args_repr = repr(cache_args).encode('utf-8') + key = '%s.args%s' % (key, hexlify(cache_args_repr)) if kwargs and not ignore_arguments: - key = '%s.kwargs%s' % (key, hexlify(repr(kwargs))) + kwargs_repr = repr(kwargs).encode('utf-8') + key = '%s.kwargs%s' % (key, hexlify(kwargs_repr)) result = _djcache.get(key) if result is None: - result = f(*args, **kwargs) + result = function(*args, **kwargs) _djcache.set(key, result, timeout) return result - return x + return wrapped return do_cache
Modified: geany/management/commands/dump_database.py 10 lines changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -28,6 +28,12 @@ class Command(BaseCommand):
# ---------------------------------------------------------------------- def handle(self, *args, **options): + self._dump_main_database() + self._remove_sensitive_information_from_dump() + self._dump_nightly_builds_database() + + # ---------------------------------------------------------------------- + def _dump_main_database(self): print('Dump main database') call_command( 'dumpdata', @@ -38,6 +44,8 @@ def handle(self, *args, **options): '--indent', '2', '--output', 'database.json')
+ # ---------------------------------------------------------------------- + def _remove_sensitive_information_from_dump(self): # remove potential sensitive information with open('database.json') as data_input: data = load(data_input) @@ -77,6 +85,8 @@ def handle(self, *args, **options): with open('database.json', 'w') as output: dump(data, output, indent=2)
+ # ---------------------------------------------------------------------- + def _dump_nightly_builds_database(self): # dump nightly builds database but limit the data to the last week # to reduce dump size now_a_week_ago = timezone.now() - timedelta(days=7)
Modified: geany/settings.py 9 lines changed, 4 insertions(+), 5 deletions(-) =================================================================== @@ -527,16 +527,15 @@
# Instead of doing "from .local_settings import *", we use exec so that # local_settings has full access to everything defined in this module. - -filename = os.path.join(PROJECT_APP_PATH, 'local_settings.py') +filename = os.path.join(PROJECT_APP_PATH, 'local_settings.py') # pylint: disable=invalid-name if os.path.exists(filename): import sys import imp - module_name = '{}.local_settings'.format(PROJECT_APP) - module = imp.new_module(module_name) + module_name = '{}.local_settings'.format(PROJECT_APP) # pylint: disable=invalid-name + module = imp.new_module(module_name) # pylint: disable=invalid-name module.__file__ = filename sys.modules[module_name] = module - exec(open(filename, 'rb').read()) + exec(open(filename, 'rb').read()) # pylint: disable=exec-used
####################
Modified: geany/sitemaps.py 36 lines changed, 17 insertions(+), 19 deletions(-) =================================================================== @@ -19,20 +19,18 @@ from mezzanine.core.sitemaps import DisplayableSitemap
-""" -Sitemap generation -GeanyMainSitemap is the main class which generates sitemap items -for all Mezzaine pages, blog posts, News posts and various static -items. - -Other apps might add their own sitemap generator classes to the -"sitemap_registry" provided by this module. For performance reasons, -static sitemap items (i.e. items generated from URLconf patterns) are -generated already on module-level because they never changed during -the whole application lifetime. -In addition, dynamic items (such as Pages and news posts) are added to -the static items at runtime as they may change at any time. -""" +# Sitemap generation +# GeanyMainSitemap is the main class which generates sitemap items +# for all Mezzaine pages, blog posts, News posts and various static +# items. +# +# Other apps might add their own sitemap generator classes to the +# "sitemap_registry" provided by this module. For performance reasons, +# static sitemap items (i.e. items generated from URLconf patterns) are +# generated already on module-level because they never changed during +# the whole application lifetime. +# In addition, dynamic items (such as Pages and news posts) are added to +# the static items at runtime as they may change at any time.
class GeanyMainSitemap(DisplayableSitemap): @@ -59,7 +57,7 @@ def lastmod(self, obj): return getattr(obj, 'publish_date', None)
-class SitemapItem(object): +class SitemapItem: """Simulate a model, mainly to provide get_absolute_url() for Sitemaps"""
# ---------------------------------------------------------------------- @@ -134,11 +132,11 @@ def get_dynamic_items(self): return list()
# ---------------------------------------------------------------------- - def changefreq(self, obj): + def changefreq(self, obj): # pylint: disable=unused-argument return 'monthly'
# ---------------------------------------------------------------------- - def location(self, obj): + def location(self, obj): # pylint: disable=unused-argument return self._url_mapping[obj.name]
# ---------------------------------------------------------------------- @@ -147,7 +145,7 @@ def get_urls(self, page=1, site=None, protocol=None): return super(StaticSitemap, self).get_urls(page, self._site, protocol)
-class SitemapRegistry(object): +class SitemapRegistry:
# ---------------------------------------------------------------------- def __init__(self): @@ -193,4 +191,4 @@ def _get_dynamic_items(self): return dynamic_items
-sitemap_registry = SitemapRegistry() +sitemap_registry = SitemapRegistry() # pylint: disable=invalid-name
Modified: geany/templatetags/geany_tags.py 12 lines changed, 6 insertions(+), 6 deletions(-) =================================================================== @@ -20,7 +20,7 @@
register = Library() -logger = logging.getLogger(__name__) +logger = logging.getLogger(__name__) # pylint: disable=invalid-name
class EvaluateNode(template.Node): @@ -38,15 +38,15 @@ def render(self, context): content_template = template.Template(content) rendered_content = content_template.render(context) context[self._target_var_name] = rendered_content - except (template.VariableDoesNotExist, template.TemplateSyntaxError) as e: - return 'Error rendering: {}'.format(e) + except (template.VariableDoesNotExist, template.TemplateSyntaxError) as exc: + return 'Error rendering: {}'.format(exc)
return ''
# ---------------------------------------------------------------------- @register.tag(name='evaluate') -def do_evaluate(parser, token): +def do_evaluate(parser, token): # pylint: disable=unused-argument """ tag usage {% evaluate object.textfield %} """ @@ -65,8 +65,8 @@ def get_irc_userlist(): try: with open(settings.IRC_USER_LIST_FILE) as file_h: user_list = file_h.readlines() - except IOError as e: - logger.error('An error occurred reading IRC user list: {}'.format(e), exc_info=True) + except IOError as exc: + logger.error('An error occurred reading IRC user list: {}'.format(exc), exc_info=True)
# remove newline characters user_list = [username.strip() for username in user_list]
Modified: geany/urls.py 4 lines changed, 3 insertions(+), 1 deletions(-) =================================================================== @@ -27,6 +27,8 @@ from nightlybuilds.views import NightlyBuildsView
+# pylint: disable=invalid-name + sitemaps = {"sitemaps": {"all": GeanyMainSitemap}}
@@ -48,7 +50,7 @@ # use our custom sitemap implementation url(r"^sitemap.xml$", sitemap, sitemaps),
- # TODO, NEWS, etc. + # Release Notes, NEWS, etc. url(r"^", include("static_docs.urls")),
# nightly builds
Modified: geany/urls_legacy.py 8 lines changed, 5 insertions(+), 3 deletions(-) =================================================================== @@ -64,7 +64,8 @@ '/Support/I18N': '/contribute/translation/', '/Support/IRC': '/support/irc/', '/Support/MailingList': '/support/mailing-lists/', - '/Support/PluginWishlist': 'https://github.com/geany/geany-plugins/issues?q=is%%3Aissue+label%%3Afeature...', + '/Support/PluginWishlist': + 'https://github.com/geany/geany-plugins/issues?q=is%%3Aissue+label%%3Afeature...', '/Support/Plugins': '/support/plugins/', '/Support/RunningOnWindows': 'https://wiki.geany.org/howtos/win32/running', '/Support/VerifyGPGSignature': '/support/verify-gpg-signature/', @@ -78,7 +79,8 @@ '/Main/20060519': '/news/geany-has-got-an-additional-developer/', '/Main/20060604': '/news/geany-07-released/', '/Main/20060608': '/news/windows-build-of-geany-07/', - '/Main/20060623': '/news/new-website-launched-with-some-new-content-and-new-layout-driven-by-a-wiki/', + '/Main/20060623': + '/news/new-website-launched-with-some-new-content-and-new-layout-driven-by-a-wiki/', '/Main/20060625': '/news/geany-071-released/', '/Main/20060809': '/news/geany-08-released/', '/Main/20060929': '/news/geany-09-released/', @@ -150,7 +152,7 @@ }
-urlpatterns = [] +urlpatterns = [] # pylint: disable=invalid-name for old_url, new_url in URL_MAPPING.items(): if old_url.startswith('/'): old_url = old_url[1:]
Modified: latest_version/models.py 12 lines changed, 4 insertions(+), 8 deletions(-) =================================================================== @@ -29,19 +29,15 @@ class Meta: verbose_name_plural = 'Latest Version'
# ---------------------------------------------------------------------- - def save(self): + def save(self, *args, **kwargs): # pylint: disable=arguments-differ """Save but replace the existing row instead of adding a new one""" - self.id = 1 - models.Model.save(self) + self.id = 1 # pylint: disable=invalid-name,attribute-defined-outside-init + super(LatestVersion, self).save(*args, **kwargs)
# ---------------------------------------------------------------------- - def delete(self): + def delete(self, using=None, keep_parents=False): """Never delete anything"""
- # ---------------------------------------------------------------------- - def __unicode__(self): - return str(self) - # ---------------------------------------------------------------------- def __str__(self): return 'Geany {}'.format(self.version)
Modified: latest_version/urls.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -18,7 +18,7 @@ from geany.sitemaps import sitemap_registry, StaticSitemap
-urlpatterns = ( +urlpatterns = ( # pylint: disable=invalid-name # compat / special url for the UpdateChecker Geany plugin url( r'^service/version.php',
Modified: news/models.py 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -85,7 +85,7 @@ class Meta: verbose_name_plural = _('News')
# ---------------------------------------------------------------------- - def save(self, *args, **kwargs): + def save(self, *args, **kwargs): # pylint: disable=arguments-differ if not self.slug: self.slug = slugify(self.title) super(NewsPost, self).save(*args, **kwargs) @@ -95,5 +95,5 @@ def get_absolute_url(self): return reverse('news_detail', kwargs={'newspost_slug': self.slug})
# ---------------------------------------------------------------------- - def __unicode__(self): + def __str__(self): return self.title
Modified: news/urls.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -20,7 +20,7 @@ from news.views import NewsDetailView, NewsListView
-urlpatterns = ( +urlpatterns = ( # pylint: disable=invalid-name url(r'^$', NewsListView.as_view(), name='news_list'), url(r'^feed/$', LatestNewsPostsFeed(), name='news_feed'), url(r'^(?P<newspost_slug>.+)/$', NewsDetailView.as_view(), name='news_detail'),
Modified: news/views.py 16 lines changed, 5 insertions(+), 11 deletions(-) =================================================================== @@ -17,13 +17,13 @@ from django.template.defaultfilters import date, safe from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.views.generic import DetailView, ListView, View +from django.views.generic import ListView, View from mezzanine.core.templatetags.mezzanine_tags import richtext_filters
from news.models import NewsPost
-class NewsPostPublishedMixin(object): +class NewsPostPublishedMixin:
# ---------------------------------------------------------------------- def get_queryset(self): @@ -40,27 +40,21 @@ class NewsListView(NewsPostPublishedMixin, ListView): template_name = 'news/list.html'
-class NewsDetailView2(NewsPostPublishedMixin, DetailView): - - model = NewsPost - template_name = 'news/detail.html' - - class NewsDetailView(NewsPostPublishedMixin, View): template_name = 'news/detail.html'
# ---------------------------------------------------------------------- @method_decorator(csrf_exempt) - def dispatch(self, *args, **kwargs): - return super(NewsDetailView, self).dispatch(*args, **kwargs) + def dispatch(self, request, *args, **kwargs): + return super(NewsDetailView, self).dispatch(request, *args, **kwargs)
# ---------------------------------------------------------------------- def get(self, request, newspost_slug): newspost = get_object_or_404(NewsPost, slug=newspost_slug) return render(request, self.template_name, {'newspost': newspost})
# ---------------------------------------------------------------------- - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # pylint: disable=unused-argument newspost_slug = request.POST.get('newspost_slug') try: newspost = NewsPost.objects.get(slug=newspost_slug)
Modified: nightlybuilds/database_routers.py 10 lines changed, 6 insertions(+), 4 deletions(-) =================================================================== @@ -12,8 +12,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
+# pylint: disable=protected-access,unused-argument
-class NightlyBuildsRouter(object): + +class NightlyBuildsRouter: """ A router to control all database operations on models in the nightlybuilds application. @@ -47,6 +49,6 @@ def allow_relation(self, obj1, obj2, **hints): return None
# ---------------------------------------------------------------------- - def allow_migrate(self, db, app_label, model_name=None, **hints): - return (db != 'nightlybuilds' and app_label != 'nightlybuilds') \ - or (db == 'nightlybuilds' and app_label == 'nightlybuilds') + def allow_migrate(self, database, app_label, model_name=None, **hints): + return (database != 'nightlybuilds' and app_label != 'nightlybuilds') \ + or (database == 'nightlybuilds' and app_label == 'nightlybuilds')
Modified: nightlybuilds/models.py 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -35,8 +35,8 @@ class Meta: db_table = 'nightly_build_target'
# ---------------------------------------------------------------------- - def __unicode__(self): - return '%s %s' % (self.name, self.arch) + def __str__(self): + return '{} {}'.format(self.name, self.arch)
class NightlyBuild(models.Model): @@ -70,5 +70,5 @@ def get_status_text(self): return 'Build failed, see the logs for details'
# ---------------------------------------------------------------------- - def __unicode__(self): - return '%s %s' % (self.build_date, self.nightly_build_target) + def __str__(self): + return '{} {}'.format(self.build_date, self.nightly_build_target)
Modified: nightlybuilds/templatetags/nightlybuilds_tags.py 6 lines changed, 3 insertions(+), 3 deletions(-) =================================================================== @@ -20,7 +20,7 @@
register = template.Library() -base_dir = settings.NIGHTLYBUILDS_BASE_DIR +BASE_DIR = settings.NIGHTLYBUILDS_BASE_DIR
# ---------------------------------------------------------------------- @@ -32,7 +32,7 @@ def get_build_log(nightly_build, log_type): log = nightly_build.log_stderr
if log: - logfile_path = os.path.join(base_dir, nightly_build.nightly_build_target.folder, log) + logfile_path = os.path.join(BASE_DIR, nightly_build.nightly_build_target.folder, log) try: size = os.stat(logfile_path).st_size except (IOError, OSError): @@ -50,7 +50,7 @@ def get_build_log(nightly_build, log_type): # ---------------------------------------------------------------------- @register.simple_tag def get_details(nightly_build): - header_txt = os.path.join(base_dir, nightly_build.nightly_build_target.folder, 'HEADER.txt') + header_txt = os.path.join(BASE_DIR, nightly_build.nightly_build_target.folder, 'HEADER.txt') if os.path.exists(header_txt): return format_html( '<a href="/{}/">Details</a>',
Modified: pastebin/api/create.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -72,7 +72,7 @@ class SnippetValidationError(Exception): pass
-class CreateSnippetApiController(object): +class CreateSnippetApiController:
valid_fields = ('title', 'content', 'expires', 'author', 'lexer')
Modified: pastebin/forms.py 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -68,7 +68,7 @@ def clean_content(self): return content
# ---------------------------------------------------------------------- - def save(self, *args, **kwargs): + def save(self, *args, **kwargs): # pylint: disable=arguments-differ # Set parent snippet parent = kwargs.pop('parent', None) if parent: @@ -79,7 +79,7 @@ def save(self, *args, **kwargs): timedelta(seconds=int(self.cleaned_data['expire_options']))
# Save snippet in the db - forms.ModelForm.save(self, *args, **kwargs) + super(SnippetForm, self).save(self, *args, **kwargs)
# Add snippet to the user's session if not self.request.session.get('snippet_list', False):
Modified: pastebin/highlight.py 9 lines changed, 5 insertions(+), 4 deletions(-) =================================================================== @@ -14,8 +14,9 @@
from django.utils.html import escape from pygments import highlight -from pygments.formatters import HtmlFormatter -from pygments.lexers import get_all_lexers, get_lexer_by_name, PythonLexer +from pygments.formatters.html import HtmlFormatter +from pygments.lexers import get_all_lexers, get_lexer_by_name +from pygments.lexers.python import PythonLexer
LEXER_LIST_ALL = sorted([(i[1][0], i[0]) for i in get_all_lexers()]) @@ -56,8 +57,8 @@ def wrap(self, source, outfile):
# ---------------------------------------------------------------------- def _wrap_code(self, source): - for j, t in source: - yield j, t + for code, text in source: + yield code, text
# ----------------------------------------------------------------------
Modified: pastebin/management/commands/generate_snippets_css.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -13,7 +13,7 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
from django.core.management.base import BaseCommand -from pygments.formatters import HtmlFormatter +from pygments.formatters.html import HtmlFormatter
class Command(BaseCommand):
Modified: pastebin/models.py 16 lines changed, 8 insertions(+), 8 deletions(-) =================================================================== @@ -25,12 +25,12 @@ from pastebin.highlight import LEXER_DEFAULT
-t = 'abcdefghijkmnopqrstuvwwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ1234567890' +CHARS = 'abcdefghijkmnopqrstuvwwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ1234567890'
# ---------------------------------------------------------------------- def generate_secret_id(length=5): - return ''.join([random.choice(t) for i in range(length)]) # pylint: disable=unused-variable + return ''.join([random.choice(CHARS) for i in range(length)]) # pylint: disable=unused-variable
class Snippet(models.Model): @@ -97,22 +97,22 @@ def content_splitted(self): return self.content_highlighted.splitlines()
# ---------------------------------------------------------------------- - def save(self, *args, **kwargs): + def save(self, *args, **kwargs): # pylint: disable=arguments-differ if not self.pk and not self.secret_id: self.secret_id = generate_secret_id() if not self.published: self.published = timezone.now()
self.content_highlighted = self.content - models.Model.save(self, *args, **kwargs) + super(Snippet, self).save(*args, **kwargs)
# ---------------------------------------------------------------------- def get_absolute_url(self): return reverse('snippet_details', kwargs={'snippet_id': self.secret_id})
# ---------------------------------------------------------------------- - def __unicode__(self): - return '%s' % self.secret_id + def __str__(self): + return '{}'.format(self.secret_id)
class SpamwordManager(models.Manager): @@ -129,5 +129,5 @@ class Spamword(models.Model): objects = SpamwordManager()
# ---------------------------------------------------------------------- - def __unicode__(self): - return self.word + def __str__(self): + return '{}'.format(self.word)
Modified: pastebin/templatetags/pastebin_tags.py 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -22,7 +22,7 @@ NINETY_YEARS_IN_DAYS = 32850 # 90 * 365
-register = Library() # pylint: disable=invalid-name +register = Library()
# ---------------------------------------------------------------------- @@ -46,9 +46,9 @@ def timeuntil_or_forever(snippet_expire): # ---------------------------------------------------------------------- @register.filter def highlight(snippet, line_count=None): - h = pygmentize(snippet.content, snippet.lexer) - if h: - lines = h.splitlines() + highlighted = pygmentize(snippet.content, snippet.lexer) + if highlighted: + lines = highlighted.splitlines() else: lines = snippet.content.splitlines()
Modified: pastebin/urls.py 25 lines changed, 20 insertions(+), 5 deletions(-) =================================================================== @@ -28,16 +28,31 @@
urlpatterns = ( # pylint: disable=invalid-name - url(r'^help/$', TemplateView.as_view(template_name='pastebin/help.html'), name='snippet_help'), - url(r'^help/api/$', TemplateView.as_view(template_name='pastebin/api.html'), name='snippet_help_api'), + url( + r'^help/$', + TemplateView.as_view(template_name='pastebin/help.html'), + name='snippet_help'), + url( + r'^help/api/$', + TemplateView.as_view(template_name='pastebin/api.html'), + name='snippet_help_api'),
url(r'^api/$', never_cache(SnippetAPIView.as_view()), name='snippet_api'),
url(r'^$', never_cache(SnippetNewView.as_view()), name='snippet_new'), url(r'^latest/$', LatestSnippetsView.as_view(), name='snippet_list'), - url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/$', SnippetDetailView.as_view(), name='snippet_details'), - url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/delete/$', SnippetDeleteView.as_view(), name='snippet_delete'), - url(r'^(?P<snippet_id>[a-zA-Z0-9]+)/raw/$', SnippetDetailRawView.as_view(), name='snippet_details_raw'), + url( + r'^(?P<snippet_id>[a-zA-Z0-9]+)/$', + SnippetDetailView.as_view(), + name='snippet_details'), + url( + r'^(?P<snippet_id>[a-zA-Z0-9]+)/delete/$', + SnippetDeleteView.as_view(), + name='snippet_delete'), + url( + r'^(?P<snippet_id>[a-zA-Z0-9]+)/raw/$', + SnippetDetailRawView.as_view(), + name='snippet_details_raw'), )
Modified: pastebin/views.py 20 lines changed, 10 insertions(+), 10 deletions(-) =================================================================== @@ -52,8 +52,8 @@ class SnippetNewView(View):
# ---------------------------------------------------------------------- @method_decorator(check_honeypot) - def dispatch(self, *args, **kwargs): - return super(SnippetNewView, self).dispatch(*args, **kwargs) + def dispatch(self, request, *args, **kwargs): + return super(SnippetNewView, self).dispatch(request, *args, **kwargs)
# ---------------------------------------------------------------------- def get(self, request): @@ -85,8 +85,8 @@ class SnippetDetailView(View):
# ---------------------------------------------------------------------- @method_decorator(check_honeypot) - def dispatch(self, *args, **kwargs): - return super(SnippetDetailView, self).dispatch(*args, **kwargs) + def dispatch(self, request, *args, **kwargs): + return super(SnippetDetailView, self).dispatch(request, *args, **kwargs)
# ---------------------------------------------------------------------- def get(self, request, snippet_id): @@ -95,9 +95,9 @@ def get(self, request, snippet_id): # load snippet try: snippet = self._fetch_snippet(snippet_id) - except SnippetNotFoundError as e: + except SnippetNotFoundError as exc: # 404 response with custom message - context = dict(message=e) + context = dict(message=exc) return TemplateResponse(request, 'errors/404.html', context=context, status=404)
new_snippet_initial = dict(content=snippet.content, lexer=snippet.lexer) @@ -187,16 +187,16 @@ class SnippetAPIView(View):
# ---------------------------------------------------------------------- @method_decorator(csrf_exempt) - def dispatch(self, *args, **kwargs): - return super(SnippetAPIView, self).dispatch(*args, **kwargs) + def dispatch(self, request, *args, **kwargs): + return super(SnippetAPIView, self).dispatch(request, *args, **kwargs)
# ---------------------------------------------------------------------- def post(self, request): try: controller = CreateSnippetApiController(request) snippet = controller.create() - except SnippetValidationError as e: - return HttpResponseBadRequest(str(e), content_type='text/plain') + except SnippetValidationError as exc: + return HttpResponseBadRequest(str(exc), content_type='text/plain')
site = self._get_site(request) absolute_url = snippet.get_absolute_url()
Modified: static_docs/generate_i18n_statistics.py 14 lines changed, 7 insertions(+), 7 deletions(-) =================================================================== @@ -27,7 +27,7 @@ LAST_TRANSLATOR_REGEXP = re.compile(r'^"Last-Translator: (?P<name>[\w -]+)\s*<?.+')
-class TranslationStatistics(object): +class TranslationStatistics:
# ---------------------------------------------------------------------- def __init__( @@ -46,7 +46,7 @@ def __init__( self.percentage_untranslated = percentage_untranslated
-class MessageCatalog(object): +class MessageCatalog:
# ---------------------------------------------------------------------- def __init__(self, filename, language_name, language_code, last_translator, statistics=None): @@ -60,11 +60,11 @@ def __init__(self, filename, language_name, language_code, last_translator, stat class SimpleObjectToJSONEncoder(JSONEncoder):
# ---------------------------------------------------------------------- - def default(self, o): + def default(self, o): # pylint: disable=method-hidden return o.__dict__
-class TranslationStatisticsGenerator(object): +class TranslationStatisticsGenerator:
# ---------------------------------------------------------------------- def __init__(self, domain, source_path, destination_path, target_filename): @@ -116,12 +116,12 @@ def _execute_command(self, command): env=environment, cwd=self._destination_path, stderr=STDOUT) - except CalledProcessError as e: + except CalledProcessError as exc: raise ValueError( 'Command: "{}" exited with code {}: {}'.format( command, - e.returncode, - e.output)) + exc.returncode, + exc.output))
# ---------------------------------------------------------------------- def _fetch_pot_stats(self):
Modified: static_docs/github_client.py 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -24,10 +24,10 @@ GITHUB_REPOSITORY = 'geany' HTTP_REQUEST_TIMEOUT = 10
-logger = logging.getLogger(__name__) +logger = logging.getLogger(__name__) # pylint: disable=invalid-name
-class GitHubApiClient(object): +class GitHubApiClient: """"""
# ----------------------------------------------------------------------
Modified: static_docs/urls.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -17,7 +17,7 @@ from static_docs.views import I18NStatisticsView, ReleaseNotesView, ToDoView
-urlpatterns = ( +urlpatterns = ( # pylint: disable=invalid-name url(r'^documentation/todo/$', ToDoView.as_view(), name='todo'),
url(r'^documentation/releasenotes/$', ReleaseNotesView.as_view(), name='releasenotes'),
Modified: static_docs/views.py 11 lines changed, 6 insertions(+), 5 deletions(-) =================================================================== @@ -29,10 +29,10 @@ RELEASE_REGEXP = re.compile(r'^Geany (?P<version>[0-9.]+) ((?P<date>.*))$') DATE_PATTERNS_TO_BE_IGNORED = ('TBD', 'TBA', 'unreleased')
-logger = logging.getLogger(__name__) +logger = logging.getLogger(__name__) # pylint: disable=invalid-name
-class ReleaseDto(object): +class ReleaseDto: """Simple data holder"""
# ---------------------------------------------------------------------- @@ -68,10 +68,11 @@ class ReleaseNotesView(StaticDocsView): template_name = 'pages/documentation/releasenotes.html'
# ---------------------------------------------------------------------- - def get_context_data(self, version=None, **kwargs): + def get_context_data(self, **kwargs): releases = self._get_release_notes() release = None
+ version = kwargs.get('version', None) if version is not None: # search for the requested release in the list (we could index the list into a # dictionary but we need the index only at this point) @@ -129,8 +130,8 @@ def _parse_release_line(self, line): match = RELEASE_REGEXP.match(line) if match: return match.group('version'), match.group('date') - else: - logger.warn('Failed parsing NEWS file: release line "%s" invalid', line) + + logger.warning('Failed parsing NEWS file: release line "%s" invalid', line) return None, None
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).