From c1e39d9a7fb95598f1f8d4d063e5e9725a713d6e Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Sun, 29 Apr 2018 11:47:24 +0200 Subject: [PATCH] Require Python3 across the board. Removed unicode --- .travis.yml | 9 ++------- docs/conf.py | 20 +++++++++---------- docs/settings.rst | 20 +++++++++---------- dpaste/forms.py | 4 ++-- .../management/commands/cleanup_snippets.py | 2 +- dpaste/models.py | 18 ++++++++--------- dpaste/tests/test_api.py | 2 +- dpaste/tests/test_snippet.py | 8 ++++---- dpaste/views.py | 6 +++--- setup.py | 3 +-- tox.ini | 2 +- 11 files changed, 44 insertions(+), 50 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97dfa47..d05b60d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,16 @@ language: python python: - - 2.7 - 3.4 - 3.5 - 3.6 + - 3.7-dev env: - DJANGO: django>=1.11,<2.0 - DJANGO: django>=2.0 -matrix: - exclude: - - python: "2.7" - env: DJANGO=2.0.* - -before_install: +before_install: - pip install coverage codacy-coverage - coverage erase diff --git a/docs/conf.py b/docs/conf.py index 689788d..574829f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,10 +42,10 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'dpaste' -copyright = u'2013, Martin Mahner' +project = 'dpaste' +copyright = '2013, Martin Mahner' -# The version info for the project you're documenting, acts as replacement for +# The version info for the project yo're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # @@ -102,7 +102,7 @@ try: except ImportError: sys.stderr.write('Sphinx "rtd" theme is not installed.' 'Fallback to regular theme.') - + # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'default' @@ -203,8 +203,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'dpaste.tex', u'dpaste Documentation', - u'Martin Mahner', 'manual'), + ('index', 'dpaste.tex', 'dpaste Documentation', + 'Martin Mahner', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -233,8 +233,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'dpaste', u'dpaste Documentation', - [u'Martin Mahner'], 1) + ('index', 'dpaste', 'dpaste Documentation', + ['Martin Mahner'], 1) ] # If true, show URL addresses after external links. @@ -247,8 +247,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'dpaste', u'dpaste Documentation', - u'Martin Mahner', 'dpaste', 'One line description of project.', + ('index', 'dpaste', 'dpaste Documentation', + 'Martin Mahner', 'dpaste', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/settings.rst b/docs/settings.rst index d739855..8af104c 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -51,10 +51,10 @@ behavior without touching the code: from django.utils.translation import ugettext_lazy as _ DPASTE_EXPIRE_CHOICES = ( - (3600, _(u'In one hour')), - (3600 * 24 * 7, _(u'In one week')), - (3600 * 24 * 30, _(u'In one month')), - (3600 * 24 * 30 * 12 * 100, _(u'100 Years')), + (3600, _('In one hour')), + (3600 * 24 * 7, _('In one week')), + (3600 * 24 * 30, _('In one month')), + (3600 * 24 * 30 * 12 * 100, _('100 Years')), ) **One-Time snippets** are supported. One-Time snippets are automatically @@ -64,10 +64,10 @@ behavior without touching the code: from django.utils.translation import ugettext_lazy as _ DPASTE_EXPIRE_CHOICES = ( - ('onetime', _(u'One-Time snippet')), - (3600, _(u'In one hour')), - (3600 * 24 * 7, _(u'In one week')), - (3600 * 24 * 30, _(u'In one month')), + ('onetime', _('One-Time snippet')), + (3600, _('In one hour')), + (3600 * 24 * 7, _('In one week')), + (3600 * 24 * 30, _('In one month')), ) You can also set the maximum view count after what the snippet gets @@ -82,8 +82,8 @@ behavior without touching the code: from django.utils.translation import ugettext_lazy as _ DPASTE_EXPIRE_CHOICES = ( - (3600, _(u'In one hour')), - (u'never', _(u'Never')), + (3600, _('In one hour')), + ('never', _('Never')), ) ``DPASTE_EXPIRE_DEFAULT`` diff --git a/dpaste/forms.py b/dpaste/forms.py index af813b3..4a681e5 100644 --- a/dpaste/forms.py +++ b/dpaste/forms.py @@ -21,10 +21,10 @@ EXPIRE_DEFAULT = getattr(settings, 'DPASTE_EXPIRE_DEFAULT', 3600) MAX_CONTENT_LENGTH = getattr(settings, 'DPASTE_MAX_CONTENT_LENGTH', 250*1024*1024) def get_expire_values(expires): - if expires == u'never': + if expires == 'never': expire_type = Snippet.EXPIRE_KEEP expires = None - elif expires == u'onetime': + elif expires == 'onetime': expire_type = Snippet.EXPIRE_ONETIME expires = None else: diff --git a/dpaste/management/commands/cleanup_snippets.py b/dpaste/management/commands/cleanup_snippets.py index dcb1664..b593034 100644 --- a/dpaste/management/commands/cleanup_snippets.py +++ b/dpaste/management/commands/cleanup_snippets.py @@ -24,6 +24,6 @@ class Command(BaseCommand): for d in deleteable_snippets: self.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires)) if options.get('dry_run'): - self.stdout.write(u'Dry run - Not actually deleting snippets!\n') + self.stdout.write('Dry run - Not actually deleting snippets!\n') else: deleteable_snippets.delete() diff --git a/dpaste/models.py b/dpaste/models.py index c0f97c6..28b6e75 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -37,22 +37,22 @@ class Snippet(models.Model): EXPIRE_KEEP = 2 EXPIRE_ONETIME = 3 EXPIRE_CHOICES = ( - (EXPIRE_TIME, _(u'Expire by timestamp')), - (EXPIRE_KEEP, _(u'Keep Forever')), - (EXPIRE_ONETIME, _(u'One-Time snippet')), + (EXPIRE_TIME, _('Expire by timestamp')), + (EXPIRE_KEEP, _('Keep Forever')), + (EXPIRE_ONETIME, _('One-Time snippet')), ) secret_id = models.CharField( - _(u'Secret ID'), max_length=255, blank=True, null=True, unique=True) - content = models.TextField(_(u'Content')) + _('Secret ID'), max_length=255, blank=True, null=True, unique=True) + content = models.TextField(_('Content')) lexer = models.CharField( - _(u'Lexer'), max_length=30, default=highlight.LEXER_DEFAULT) + _('Lexer'), max_length=30, default=highlight.LEXER_DEFAULT) published = models.DateTimeField( - _(u'Published'), auto_now_add=True) + _('Published'), auto_now_add=True) expire_type = models.PositiveSmallIntegerField( - _(u'Expire Type'), choices=EXPIRE_CHOICES, default=EXPIRE_CHOICES[0][0]) + _('Expire Type'), choices=EXPIRE_CHOICES, default=EXPIRE_CHOICES[0][0]) expires = models.DateTimeField( - _(u'Expires'), blank=True, null=True) + _('Expires'), blank=True, null=True) view_count = models.PositiveIntegerField( _('View count'), default=0) parent = models.ForeignKey( diff --git a/dpaste/tests/test_api.py b/dpaste/tests/test_api.py index 063d58e..c829405 100644 --- a/dpaste/tests/test_api.py +++ b/dpaste/tests/test_api.py @@ -244,7 +244,7 @@ class SnippetAPITestCase(TestCase): """ Leading Whitespace is retained in the db. """ - content = u' one\n two\n three\n four' + content = ' one\n two\n three\n four' self.client.post(self.api_url, {'content': content}) self.assertEqual(Snippet.objects.all()[0].content, content) diff --git a/dpaste/tests/test_snippet.py b/dpaste/tests/test_snippet.py index c0171d9..8c1f1be 100644 --- a/dpaste/tests/test_snippet.py +++ b/dpaste/tests/test_snippet.py @@ -102,7 +102,7 @@ class SnippetTestCase(TestCase): the snippet is considered as spam. We let the user know its spam. """ data = self.valid_form_data() - data['title'] = u'Any content' + data['title'] = 'Any content' response = self.client.post(self.new_url, data, follow=True) self.assertEqual(response.status_code, 200) self.assertEqual(Snippet.objects.count(), 0) @@ -212,8 +212,8 @@ class SnippetTestCase(TestCase): # ------------------------------------------------------------------------- # XSS and correct escaping # ------------------------------------------------------------------------- - XSS_ORIGINAL = u'' - XSS_ESCAPED = u'<script>hello</script>' + XSS_ORIGINAL = '' + XSS_ESCAPED = '<script>hello</script>' def test_xss_text_lexer(self): # Simple 'text' lexer @@ -361,7 +361,7 @@ class SnippetTestCase(TestCase): """ Leading Whitespace is retained in the db. """ - content = u' one\n two\n three\n four' + content = ' one\n two\n three\n four' data = self.valid_form_data(content=content) self.client.post(self.new_url, data, follow=True) self.assertEqual(Snippet.objects.all()[0].content, content) diff --git a/dpaste/views.py b/dpaste/views.py index 12d32b2..077126a 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -205,16 +205,16 @@ class AboutView(TemplateView): def _format_default(s): """The default response is the snippet URL wrapped in quotes.""" - return u'"%s%s"' % (BASE_URL, s.get_absolute_url()) + return '"%s%s"' % (BASE_URL, s.get_absolute_url()) def _format_url(s): """The `url` format returns the snippet URL, no quotes, but a linebreak after.""" - return u'%s%s\n' % (BASE_URL, s.get_absolute_url()) + return '%s%s\n' % (BASE_URL, s.get_absolute_url()) def _format_json(s): """The `json` format export.""" return json.dumps({ - 'url': u'%s%s' % (BASE_URL, s.get_absolute_url()), + 'url': '%s%s' % (BASE_URL, s.get_absolute_url()), 'content': s.content, 'lexer': s.lexer, }) diff --git a/setup.py b/setup.py index e63e7ec..5d8b80c 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import find_packages, setup -long_description = u'\n\n'.join(( +long_description = '\n\n'.join(( open('README.rst').read(), open('CHANGELOG').read() )) @@ -23,7 +23,6 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Framework :: Django', ], diff --git a/tox.ini b/tox.ini index 2673934..5aa5bf7 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ toxworkdir=/tmp/tox/dpaste skip_missing_interpreters=True envlist= coverage_setup - py{27,34,35,36}-django-{111} + py{34,35,36}-django-{111} py{34,35,36}-django-{20} coverage_report