Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sun, 14 Apr 2019 22:17:53 UTC Commit: 065247ccff05f33d8d5a2baba25ea2c81b2abc8e https://github.com/geany/www.geany.org/commit/065247ccff05f33d8d5a2baba25ea2...
Log Message: ----------- Minor PEP8/Python3/Django2.0 fixes
Modified Paths: -------------- geany/templatetags/geany_tags.py pastebin/management/commands/cleanup_snippets.py pastebin/views.py
Modified: geany/templatetags/geany_tags.py 8 lines changed, 4 insertions(+), 4 deletions(-) =================================================================== @@ -39,7 +39,7 @@ def render(self, context): rendered_content = content_template.render(context) context[self._target_var_name] = rendered_content except (template.VariableDoesNotExist, template.TemplateSyntaxError) as e: - return 'Error rendering: %s' % unicode(e) + return 'Error rendering: {}'.format(e)
return ''
@@ -54,7 +54,7 @@ def do_evaluate(parser, token): _, variable, _, target_var_name = token.split_contents() except ValueError: raise template.TemplateSyntaxError( - '%r tag requires a single argument' % token.contents.split()[1]) + '{!r} tag requires a single argument'.format(token.contents.split()[1])) return EvaluateNode(variable, target_var_name)
@@ -66,7 +66,7 @@ def get_irc_userlist(): 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: %s', unicode(e), exc_info=True) + logger.error('An error occurred reading IRC user list: {}'.format(e), exc_info=True)
# remove newline characters user_list = [username.strip() for username in user_list] @@ -79,6 +79,6 @@ def add_css(field, css): # read existing CSS classes css_classes = field.field.widget.attrs.get('class', '') # add new ones - css_classes = '%s %s' % (css_classes, css) + css_classes = '{} {}'.format(css_classes, css) # render the widget return field.as_widget(attrs={'class': css_classes})
Modified: pastebin/management/commands/cleanup_snippets.py 21 lines changed, 11 insertions(+), 10 deletions(-) =================================================================== @@ -12,28 +12,29 @@ # 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/.
-from optparse import make_option -import datetime import sys
-from django.core.management.base import LabelCommand +from django.core.management.base import BaseCommand +from django.utils import timezone
from pastebin.models import Snippet
-class Command(LabelCommand): - option_list = LabelCommand.option_list + ( - make_option( +class Command(BaseCommand): + + help = 'Purges snippets that are expired' + + # ---------------------------------------------------------------------- + def add_arguments(self, parser): + parser.add_argument( '--dry-run', '-d', action='store_true', dest='dry_run', - help='Don't do anything.'), - ) - help = 'Purges snippets that are expired' + help='Don't do anything.')
# ---------------------------------------------------------------------- def handle(self, *args, **options): - deleteable_snippets = Snippet.objects.filter(expires__lte=datetime.datetime.now()) + deleteable_snippets = Snippet.objects.filter(expires__lte=timezone.now()) sys.stdout.write('{} snippets gets deleted:\n'.format(deleteable_snippets.count())) for deleteable_snippet in deleteable_snippets: sys.stdout.write(
Modified: pastebin/views.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -196,7 +196,7 @@ def post(self, request): controller = CreateSnippetApiController(request) snippet = controller.create() except SnippetValidationError as e: - return HttpResponseBadRequest(unicode(e), content_type='text/plain') + return HttpResponseBadRequest(str(e), content_type='text/plain')
site = self._get_site(request) absolute_url = snippet.get_absolute_url()
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).