From 752361071091ab7b5c829d7e38b7ac88e7d07367 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Wed, 8 Jun 2011 12:23:08 +0200 Subject: [PATCH] Whitespace fixes --- pastebin/apps/api/handlers.py | 2 +- pastebin/apps/dpaste/admin.py | 2 +- pastebin/apps/dpaste/forms.py | 14 +++++++------- pastebin/apps/dpaste/highlight.py | 2 +- .../dpaste/management/commands/cleanup_snippets.py | 8 ++++---- pastebin/apps/dpaste/models.py | 4 ++-- pastebin/apps/dpaste/urls.py | 2 +- pastebin/apps/dpaste/views.py | 6 +++--- pastebin/conf/settings.py | 4 ++-- pastebin/conf/urls.py | 7 +++---- 10 files changed, 25 insertions(+), 26 deletions(-) diff --git a/pastebin/apps/api/handlers.py b/pastebin/apps/api/handlers.py index 882101c..6b4df4c 100644 --- a/pastebin/apps/api/handlers.py +++ b/pastebin/apps/api/handlers.py @@ -1,6 +1,6 @@ import datetime import re -from piston.utils import rc +from piston.utils import rc from piston.handler import AnonymousBaseHandler from pastebin.apps.dpaste.models import Snippet diff --git a/pastebin/apps/dpaste/admin.py b/pastebin/apps/dpaste/admin.py index cc851b3..45e43c0 100644 --- a/pastebin/apps/dpaste/admin.py +++ b/pastebin/apps/dpaste/admin.py @@ -7,4 +7,4 @@ class SnippetAdmin(admin.ModelAdmin): list_filter = ('published',) admin.site.register(Snippet, SnippetAdmin) -admin.site.register(Spamword) \ No newline at end of file +admin.site.register(Spamword) diff --git a/pastebin/apps/dpaste/forms.py b/pastebin/apps/dpaste/forms.py index b115a41..2e99317 100644 --- a/pastebin/apps/dpaste/forms.py +++ b/pastebin/apps/dpaste/forms.py @@ -25,7 +25,7 @@ class SnippetForm(forms.ModelForm): initial=LEXER_DEFAULT, label=_(u'Lexer'), ) - + expire_options = forms.ChoiceField( choices=EXPIRE_CHOICES, initial=EXPIRE_DEFAULT, @@ -35,7 +35,7 @@ class SnippetForm(forms.ModelForm): def __init__(self, request, *args, **kwargs): super(SnippetForm, self).__init__(*args, **kwargs) self.request = request - + try: if self.request.session['userprefs'].get('display_all_lexer', False): self.fields['lexer'].choices = LEXER_LIST_ALL @@ -46,7 +46,7 @@ class SnippetForm(forms.ModelForm): self.fields['author'].initial = self.request.session['userprefs'].get('default_name', '') except KeyError: pass - + def clean_content(self): content = self.cleaned_data.get('content') if content: @@ -54,17 +54,17 @@ class SnippetForm(forms.ModelForm): if regex.findall(content.lower()): raise forms.ValidationError('This snippet was identified as SPAM.') return content - + def save(self, parent=None, *args, **kwargs): # Set parent snippet if parent: self.instance.parent = parent - + # Add expire datestamp self.instance.expires = datetime.datetime.now() + \ datetime.timedelta(seconds=int(self.cleaned_data['expire_options'])) - + # Save snippet in the db super(SnippetForm, self).save(*args, **kwargs) @@ -107,7 +107,7 @@ class UserSettingsForm(forms.Form): default_name = forms.CharField(label=_(u'Default Name'), required=False) display_all_lexer = forms.BooleanField( - label=_(u'Display all lexer'), + label=_(u'Display all lexer'), required=False, widget=forms.CheckboxInput, help_text=_(u'This also enables the super secret \'guess lexer\' function.'), diff --git a/pastebin/apps/dpaste/highlight.py b/pastebin/apps/dpaste/highlight.py index 82299c2..0883c0f 100644 --- a/pastebin/apps/dpaste/highlight.py +++ b/pastebin/apps/dpaste/highlight.py @@ -48,7 +48,7 @@ def pygmentize(code_string, lexer_name=LEXER_DEFAULT): except TypeError: logger.warning('Could not highlight code with lexer "%s"' % lexer_name) return escape(code_string) - + def guess_code_lexer(code_string, default_lexer='unknown'): try: return guess_lexer(code_string).name diff --git a/pastebin/apps/dpaste/management/commands/cleanup_snippets.py b/pastebin/apps/dpaste/management/commands/cleanup_snippets.py index bafac42..82e643f 100644 --- a/pastebin/apps/dpaste/management/commands/cleanup_snippets.py +++ b/pastebin/apps/dpaste/management/commands/cleanup_snippets.py @@ -6,14 +6,14 @@ from pastebin.apps.dpaste.models import Snippet class Command(LabelCommand): option_list = LabelCommand.option_list + ( - make_option('--dry-run', '-d', action='store_true', dest='dry_run', + make_option('--dry-run', '-d', action='store_true', dest='dry_run', help='Don\'t do anything.'), ) help = "Purges snippets that are expired" - def handle(self, *args, **options): - deleteable_snippets = Snippet.objects.filter(expires__lte=datetime.datetime.now()) - sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) + def handle(self, *args, **options): + deleteable_snippets = Snippet.objects.filter(expires__lte=datetime.datetime.now()) + sys.stdout.write(u"%s snippets gets deleted:\n" % deleteable_snippets.count()) for d in deleteable_snippets: sys.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires)) if options.get('dry_run'): diff --git a/pastebin/apps/dpaste/models.py b/pastebin/apps/dpaste/models.py index 22b2f36..dd031df 100644 --- a/pastebin/apps/dpaste/models.py +++ b/pastebin/apps/dpaste/models.py @@ -10,7 +10,7 @@ from pastebin.apps.dpaste.highlight import LEXER_DEFAULT, pygmentize t = 'abcdefghijkmnopqrstuvwwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ1234567890' def generate_secret_id(length=4): - return ''.join([random.choice(t) for i in range(length)]) + return ''.join([random.choice(t) for i in range(length)]) class Snippet(models.Model): secret_id = models.CharField(_(u'Secret ID'), max_length=4, blank=True) @@ -57,6 +57,6 @@ class SpamwordManager(models.Manager): class Spamword(models.Model): word = models.CharField(max_length=100) objects = SpamwordManager() - + def __unicode__(self): return self.word diff --git a/pastebin/apps/dpaste/urls.py b/pastebin/apps/dpaste/urls.py index 65acb34..6aefb9c 100644 --- a/pastebin/apps/dpaste/urls.py +++ b/pastebin/apps/dpaste/urls.py @@ -11,4 +11,4 @@ urlpatterns = patterns('pastebin.apps.dpaste.views', url(r'^(?P[a-zA-Z0-9]{4})/$', 'snippet_details', name='snippet_details'), url(r'^(?P[a-zA-Z0-9]{4})/delete/$', 'snippet_delete', name='snippet_delete'), url(r'^(?P[a-zA-Z0-9]{4})/raw/$', 'snippet_details', {'template_name': 'dpaste/snippet_details_raw.html', 'is_raw': True}, name='snippet_details_raw'), -) \ No newline at end of file +) diff --git a/pastebin/apps/dpaste/views.py b/pastebin/apps/dpaste/views.py index dba6fd4..186073c 100644 --- a/pastebin/apps/dpaste/views.py +++ b/pastebin/apps/dpaste/views.py @@ -83,12 +83,12 @@ def snippet_delete(request, snippet_id): return HttpResponseRedirect(reverse('snippet_new')) def snippet_userlist(request, template_name='dpaste/snippet_list.html'): - + try: snippet_list = get_list_or_404(Snippet, pk__in=request.session.get('snippet_list', None)) except ValueError: snippet_list = None - + template_context = { 'snippets_max': getattr(settings, 'MAX_SNIPPETS_PER_USER', 10), 'snippet_list': snippet_list, @@ -159,7 +159,7 @@ def snippet_diff(request, template_name='dpaste/snippet_diff.html'): template_context, RequestContext(request) ) - + def guess_lexer(request): code_string = request.GET.get('codestring', False) response = simplejson.dumps({'lexer': guess_code_lexer(code_string)}) diff --git a/pastebin/conf/settings.py b/pastebin/conf/settings.py index f08653a..6633ff2 100644 --- a/pastebin/conf/settings.py +++ b/pastebin/conf/settings.py @@ -1,4 +1,4 @@ -# Import global settings to make it easier to extend settings. +# Import global settings to make it easier to extend settings. from django.conf.global_settings import * #============================================================================== @@ -22,7 +22,7 @@ SECRET_KEY = '' #============================================================================== USE_I18N = True -USE_L10N = False +USE_L10N = False LANGUAGE_CODE = 'en' LANGUAGES = ( diff --git a/pastebin/conf/urls.py b/pastebin/conf/urls.py index fb078d0..b235903 100644 --- a/pastebin/conf/urls.py +++ b/pastebin/conf/urls.py @@ -9,14 +9,13 @@ snippet_resource = Resource(handler=SnippetHandler) urlpatterns = patterns('', (r'^', include('pastebin.apps.dpaste.urls')), - + # Static url(r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html'}, name='about'), - + url(r'^admin/', include(admin.site.urls)), - + # API url(r'^api/(?P[^/]+)/$', snippet_resource), url(r'^api/$', snippet_resource), ) -