From b25b9b888e6b7f605ef72733e17edfda6b03d058 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Sun, 14 Dec 2014 18:03:35 +0100 Subject: [PATCH] Cleaned up all imports using isort. --- dpaste/forms.py | 4 +-- dpaste/highlight.py | 9 +++---- .../management/commands/cleanup_snippets.py | 3 +++ dpaste/middleware.py | 1 + dpaste/migrations/0001_initial.py | 5 ++-- ...snippet_author__del_field_snippet_title.py | 5 ++-- ...__del_field_snippet_content_highlighted.py | 5 ++-- ...__chg_field_snippet_secret_id__chg_fiel.py | 5 ++-- ...pire_type__add_field_snippet_view_count.py | 5 ++-- ...0006_auto__add_unique_snippet_secret_id.py | 5 ++-- dpaste/models.py | 11 ++++---- dpaste/settings/local.py.example | 2 +- dpaste/templatetags/dpaste_tags.py | 3 ++- dpaste/tests/test_api.py | 5 ++-- dpaste/tests/test_snippet.py | 8 +++--- dpaste/urls/dpaste.py | 2 +- dpaste/urls/dpaste_api.py | 3 ++- dpaste/views.py | 25 +++++++++---------- runtests.py | 1 + setup.py | 6 +++-- 20 files changed, 63 insertions(+), 50 deletions(-) diff --git a/dpaste/forms.py b/dpaste/forms.py index afcf05e..f509174 100644 --- a/dpaste/forms.py +++ b/dpaste/forms.py @@ -4,8 +4,8 @@ from django import forms from django.conf import settings from django.utils.translation import ugettext_lazy as _ -from dpaste.models import Snippet -from dpaste.highlight import LEXER_LIST, LEXER_DEFAULT, LEXER_KEYS +from .highlight import LEXER_DEFAULT, LEXER_KEYS, LEXER_LIST +from .models import Snippet EXPIRE_CHOICES = getattr(settings, 'DPASTE_EXPIRE_CHOICES', ( ('onetime', _(u'One-Time snippet')), diff --git a/dpaste/highlight.py b/dpaste/highlight.py index 1b66a6d..750f978 100644 --- a/dpaste/highlight.py +++ b/dpaste/highlight.py @@ -1,10 +1,9 @@ -from pygments import highlight -from pygments.lexers import * -from pygments.formatters import HtmlFormatter - from django.conf import settings -from django.utils.translation import ugettext_lazy as _ from django.template.defaultfilters import escape +from django.utils.translation import ugettext_lazy as _ +from pygments import highlight +from pygments.formatters import HtmlFormatter +from pygments.lexers import * """ # Get a list of all lexer, and then remove all lexer which have '-' or '+' diff --git a/dpaste/management/commands/cleanup_snippets.py b/dpaste/management/commands/cleanup_snippets.py index c3bf873..c24e6ec 100644 --- a/dpaste/management/commands/cleanup_snippets.py +++ b/dpaste/management/commands/cleanup_snippets.py @@ -1,9 +1,12 @@ import sys from optparse import make_option + from django.core.management.base import LabelCommand from django.utils import timezone + from dpaste.models import Snippet + class Command(LabelCommand): option_list = LabelCommand.option_list + ( make_option('--dry-run', '-d', action='store_true', dest='dry_run', diff --git a/dpaste/middleware.py b/dpaste/middleware.py index 909dabc..c221240 100644 --- a/dpaste/middleware.py +++ b/dpaste/middleware.py @@ -1,4 +1,5 @@ import socket + from django.http import HttpResponseBadRequest tor_bl = ( diff --git a/dpaste/migrations/0001_initial.py b/dpaste/migrations/0001_initial.py index 0ac6008..869fb7c 100644 --- a/dpaste/migrations/0001_initial.py +++ b/dpaste/migrations/0001_initial.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -66,4 +67,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/migrations/0002_auto__del_spamword__del_field_snippet_author__del_field_snippet_title.py b/dpaste/migrations/0002_auto__del_spamword__del_field_snippet_author__del_field_snippet_title.py index af3c568..4e483b8 100644 --- a/dpaste/migrations/0002_auto__del_spamword__del_field_snippet_author__del_field_snippet_title.py +++ b/dpaste/migrations/0002_auto__del_spamword__del_field_snippet_author__del_field_snippet_title.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -53,4 +54,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py b/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py index 2cc1695..4d72cea 100644 --- a/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py +++ b/dpaste/migrations/0003_auto__del_field_snippet_content_highlighted.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -36,4 +37,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/migrations/0004_auto__chg_field_snippet_expires__chg_field_snippet_secret_id__chg_fiel.py b/dpaste/migrations/0004_auto__chg_field_snippet_expires__chg_field_snippet_secret_id__chg_fiel.py index b73cd01..ae2bd24 100644 --- a/dpaste/migrations/0004_auto__chg_field_snippet_expires__chg_field_snippet_secret_id__chg_fiel.py +++ b/dpaste/migrations/0004_auto__chg_field_snippet_expires__chg_field_snippet_secret_id__chg_fiel.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -46,4 +47,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/migrations/0005_auto__add_field_snippet_expire_type__add_field_snippet_view_count.py b/dpaste/migrations/0005_auto__add_field_snippet_expire_type__add_field_snippet_view_count.py index 2a5e275..c943cb4 100644 --- a/dpaste/migrations/0005_auto__add_field_snippet_expire_type__add_field_snippet_view_count.py +++ b/dpaste/migrations/0005_auto__add_field_snippet_expire_type__add_field_snippet_view_count.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -46,4 +47,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/migrations/0006_auto__add_unique_snippet_secret_id.py b/dpaste/migrations/0006_auto__add_unique_snippet_secret_id.py index caf5026..d00596c 100644 --- a/dpaste/migrations/0006_auto__add_unique_snippet_secret_id.py +++ b/dpaste/migrations/0006_auto__add_unique_snippet_secret_id.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import datetime + +from django.db import models from south.db import db from south.v2 import SchemaMigration -from django.db import models class Migration(SchemaMigration): @@ -36,4 +37,4 @@ class Migration(SchemaMigration): } } - complete_apps = ['dpaste'] \ No newline at end of file + complete_apps = ['dpaste'] diff --git a/dpaste/models.py b/dpaste/models.py index 2e5d63f..e9da20b 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -1,13 +1,12 @@ from random import SystemRandom -from django.db import IntegrityError -from django.db import models -from django.core.urlresolvers import reverse -from django.conf import settings -from django.utils.translation import ugettext_lazy as _ import mptt +from django.conf import settings +from django.core.urlresolvers import reverse +from django.db import models +from django.utils.translation import ugettext_lazy as _ -from dpaste.highlight import LEXER_DEFAULT +from .highlight import LEXER_DEFAULT R = SystemRandom() ONETIME_LIMIT = getattr(settings, 'DPASTE_ONETIME_LIMIT', 2) diff --git a/dpaste/settings/local.py.example b/dpaste/settings/local.py.example index 6c2c3ad..94010cf 100644 --- a/dpaste/settings/local.py.example +++ b/dpaste/settings/local.py.example @@ -1,4 +1,4 @@ -from dpaste.settings import * +from .settings import * DEBUG = True TEMPLATE_DEBUG = DEBUG diff --git a/dpaste/templatetags/dpaste_tags.py b/dpaste/templatetags/dpaste_tags.py index 5b6e8d1..e8de74f 100644 --- a/dpaste/templatetags/dpaste_tags.py +++ b/dpaste/templatetags/dpaste_tags.py @@ -1,5 +1,6 @@ from django.template import Library -from dpaste.highlight import pygmentize + +from ..highlight import pygmentize register = Library() diff --git a/dpaste/tests/test_api.py b/dpaste/tests/test_api.py index b9dff5b..f47ffa9 100644 --- a/dpaste/tests/test_api.py +++ b/dpaste/tests/test_api.py @@ -1,11 +1,12 @@ # -*- encoding: utf-8 -*- from django.core.urlresolvers import reverse -from django.test.client import Client from django.test import TestCase +from django.test.client import Client -from ..models import Snippet from ..highlight import PLAIN_CODE +from ..models import Snippet + class SnippetAPITestCase(TestCase): diff --git a/dpaste/tests/test_snippet.py b/dpaste/tests/test_snippet.py index 9cc724d..56eb1a3 100644 --- a/dpaste/tests/test_snippet.py +++ b/dpaste/tests/test_snippet.py @@ -4,13 +4,13 @@ from datetime import timedelta from django.core import management from django.core.urlresolvers import reverse -from django.test.client import Client from django.test import TestCase +from django.test.client import Client from django.test.utils import override_settings -from ..models import Snippet from ..forms import EXPIRE_DEFAULT -from ..highlight import LEXER_DEFAULT, PLAIN_TEXT, PLAIN_CODE +from ..highlight import LEXER_DEFAULT, PLAIN_CODE, PLAIN_TEXT +from ..models import Snippet class SnippetTestCase(TestCase): @@ -377,7 +377,7 @@ class SnippetTestCase(TestCase): def test_highlighting(self): # You can pass any lexer to the pygmentize function and it will # never fail loudly. - from dpaste.highlight import pygmentize + from ..highlight import pygmentize pygmentize('code', lexer_name='python') pygmentize('code', lexer_name='doesnotexist') diff --git a/dpaste/urls/dpaste.py b/dpaste/urls/dpaste.py index 7013a66..d074234 100644 --- a/dpaste/urls/dpaste.py +++ b/dpaste/urls/dpaste.py @@ -1,5 +1,5 @@ -from django.conf.urls import url, patterns from django.conf import settings +from django.conf.urls import patterns, url L = getattr(settings, 'DPASTE_SLUG_LENGTH', 4) diff --git a/dpaste/urls/dpaste_api.py b/dpaste/urls/dpaste_api.py index beaadc6..3722851 100644 --- a/dpaste/urls/dpaste_api.py +++ b/dpaste/urls/dpaste_api.py @@ -1,4 +1,5 @@ -from django.conf.urls import url, patterns +from django.conf.urls import patterns, url + from ..views import snippet_api urlpatterns = patterns('', diff --git a/dpaste/views.py b/dpaste/views.py index 1cd7891..820edaa 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -1,28 +1,27 @@ import datetime import difflib -import requests import json -from django.shortcuts import (render_to_response, get_object_or_404) -from django.template.context import RequestContext -from django.http import (Http404, HttpResponseRedirect, HttpResponseBadRequest, - HttpResponse) +import requests from django.conf import settings from django.core.exceptions import ObjectDoesNotExist -from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse from django.db.models import Count -from django.views.defaults import (page_not_found as django_page_not_found, - server_error as django_server_error) +from django.http import (Http404, HttpResponse, HttpResponseBadRequest, + HttpResponseRedirect) +from django.shortcuts import get_object_or_404, render_to_response +from django.template.context import RequestContext +from django.utils.translation import ugettext_lazy as _ from django.views.decorators.csrf import csrf_exempt - +from django.views.defaults import page_not_found as django_page_not_found +from django.views.defaults import server_error as django_server_error from pygments.lexers import get_lexer_for_filename from pygments.util import ClassNotFound -from dpaste.forms import SnippetForm, get_expire_values, EXPIRE_CHOICES -from dpaste.models import Snippet, ONETIME_LIMIT -from dpaste.highlight import (LEXER_DEFAULT, LEXER_KEYS, LEXER_WORDWRAP, - LEXER_LIST, PLAIN_CODE) +from .forms import EXPIRE_CHOICES, get_expire_values, SnippetForm +from .highlight import (LEXER_DEFAULT, LEXER_KEYS, LEXER_LIST, + LEXER_WORDWRAP, PLAIN_CODE) +from .models import ONETIME_LIMIT, Snippet template_globals = { 'site_name': getattr(settings, 'DPASTE_SITE_NAME', 'dpaste.de'), diff --git a/runtests.py b/runtests.py index c345b36..908cb85 100644 --- a/runtests.py +++ b/runtests.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import sys + from django.conf import settings if not settings.configured: diff --git a/setup.py b/setup.py index 681ee0c..54395fd 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,10 @@ #!/usr/bin/env python -from setuptools import setup, find_packages -from setuptools.command.test import test as TestCommand from sys import exit +from setuptools import find_packages, setup +from setuptools.command.test import test as TestCommand + + class Tox(TestCommand): def finalize_options(self): TestCommand.finalize_options(self)