mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 11:56:36 +11:00
Require Python3 across the board. Removed unicode
This commit is contained in:
parent
edf5adc541
commit
c1e39d9a7f
11 changed files with 44 additions and 50 deletions
|
@ -1,21 +1,16 @@
|
||||||
language: python
|
language: python
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- 2.7
|
|
||||||
- 3.4
|
- 3.4
|
||||||
- 3.5
|
- 3.5
|
||||||
- 3.6
|
- 3.6
|
||||||
|
- 3.7-dev
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DJANGO: django>=1.11,<2.0
|
- DJANGO: django>=1.11,<2.0
|
||||||
- DJANGO: django>=2.0
|
- DJANGO: django>=2.0
|
||||||
|
|
||||||
matrix:
|
before_install:
|
||||||
exclude:
|
|
||||||
- python: "2.7"
|
|
||||||
env: DJANGO=2.0.*
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- pip install coverage codacy-coverage
|
- pip install coverage codacy-coverage
|
||||||
- coverage erase
|
- coverage erase
|
||||||
|
|
||||||
|
|
20
docs/conf.py
20
docs/conf.py
|
@ -42,10 +42,10 @@ source_suffix = '.rst'
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'dpaste'
|
project = 'dpaste'
|
||||||
copyright = u'2013, Martin Mahner'
|
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
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
|
@ -102,7 +102,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.stderr.write('Sphinx "rtd" theme is not installed.'
|
sys.stderr.write('Sphinx "rtd" theme is not installed.'
|
||||||
'Fallback to regular theme.')
|
'Fallback to regular theme.')
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
# html_theme = 'default'
|
# html_theme = 'default'
|
||||||
|
@ -203,8 +203,8 @@ latex_elements = {
|
||||||
# (source start file, target name, title,
|
# (source start file, target name, title,
|
||||||
# author, documentclass [howto, manual, or own class]).
|
# author, documentclass [howto, manual, or own class]).
|
||||||
latex_documents = [
|
latex_documents = [
|
||||||
('index', 'dpaste.tex', u'dpaste Documentation',
|
('index', 'dpaste.tex', 'dpaste Documentation',
|
||||||
u'Martin Mahner', 'manual'),
|
'Martin Mahner', 'manual'),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# 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
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'dpaste', u'dpaste Documentation',
|
('index', 'dpaste', 'dpaste Documentation',
|
||||||
[u'Martin Mahner'], 1)
|
['Martin Mahner'], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
|
@ -247,8 +247,8 @@ man_pages = [
|
||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'dpaste', u'dpaste Documentation',
|
('index', 'dpaste', 'dpaste Documentation',
|
||||||
u'Martin Mahner', 'dpaste', 'One line description of project.',
|
'Martin Mahner', 'dpaste', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,10 @@ behavior without touching the code:
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
DPASTE_EXPIRE_CHOICES = (
|
DPASTE_EXPIRE_CHOICES = (
|
||||||
(3600, _(u'In one hour')),
|
(3600, _('In one hour')),
|
||||||
(3600 * 24 * 7, _(u'In one week')),
|
(3600 * 24 * 7, _('In one week')),
|
||||||
(3600 * 24 * 30, _(u'In one month')),
|
(3600 * 24 * 30, _('In one month')),
|
||||||
(3600 * 24 * 30 * 12 * 100, _(u'100 Years')),
|
(3600 * 24 * 30 * 12 * 100, _('100 Years')),
|
||||||
)
|
)
|
||||||
|
|
||||||
**One-Time snippets** are supported. One-Time snippets are automatically
|
**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 _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
DPASTE_EXPIRE_CHOICES = (
|
DPASTE_EXPIRE_CHOICES = (
|
||||||
('onetime', _(u'One-Time snippet')),
|
('onetime', _('One-Time snippet')),
|
||||||
(3600, _(u'In one hour')),
|
(3600, _('In one hour')),
|
||||||
(3600 * 24 * 7, _(u'In one week')),
|
(3600 * 24 * 7, _('In one week')),
|
||||||
(3600 * 24 * 30, _(u'In one month')),
|
(3600 * 24 * 30, _('In one month')),
|
||||||
)
|
)
|
||||||
|
|
||||||
You can also set the maximum view count after what the snippet gets
|
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 _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
DPASTE_EXPIRE_CHOICES = (
|
DPASTE_EXPIRE_CHOICES = (
|
||||||
(3600, _(u'In one hour')),
|
(3600, _('In one hour')),
|
||||||
(u'never', _(u'Never')),
|
('never', _('Never')),
|
||||||
)
|
)
|
||||||
|
|
||||||
``DPASTE_EXPIRE_DEFAULT``
|
``DPASTE_EXPIRE_DEFAULT``
|
||||||
|
|
|
@ -21,10 +21,10 @@ EXPIRE_DEFAULT = getattr(settings, 'DPASTE_EXPIRE_DEFAULT', 3600)
|
||||||
MAX_CONTENT_LENGTH = getattr(settings, 'DPASTE_MAX_CONTENT_LENGTH', 250*1024*1024)
|
MAX_CONTENT_LENGTH = getattr(settings, 'DPASTE_MAX_CONTENT_LENGTH', 250*1024*1024)
|
||||||
|
|
||||||
def get_expire_values(expires):
|
def get_expire_values(expires):
|
||||||
if expires == u'never':
|
if expires == 'never':
|
||||||
expire_type = Snippet.EXPIRE_KEEP
|
expire_type = Snippet.EXPIRE_KEEP
|
||||||
expires = None
|
expires = None
|
||||||
elif expires == u'onetime':
|
elif expires == 'onetime':
|
||||||
expire_type = Snippet.EXPIRE_ONETIME
|
expire_type = Snippet.EXPIRE_ONETIME
|
||||||
expires = None
|
expires = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -24,6 +24,6 @@ class Command(BaseCommand):
|
||||||
for d in deleteable_snippets:
|
for d in deleteable_snippets:
|
||||||
self.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires))
|
self.stdout.write(u"- %s (%s)\n" % (d.secret_id, d.expires))
|
||||||
if options.get('dry_run'):
|
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:
|
else:
|
||||||
deleteable_snippets.delete()
|
deleteable_snippets.delete()
|
||||||
|
|
|
@ -37,22 +37,22 @@ class Snippet(models.Model):
|
||||||
EXPIRE_KEEP = 2
|
EXPIRE_KEEP = 2
|
||||||
EXPIRE_ONETIME = 3
|
EXPIRE_ONETIME = 3
|
||||||
EXPIRE_CHOICES = (
|
EXPIRE_CHOICES = (
|
||||||
(EXPIRE_TIME, _(u'Expire by timestamp')),
|
(EXPIRE_TIME, _('Expire by timestamp')),
|
||||||
(EXPIRE_KEEP, _(u'Keep Forever')),
|
(EXPIRE_KEEP, _('Keep Forever')),
|
||||||
(EXPIRE_ONETIME, _(u'One-Time snippet')),
|
(EXPIRE_ONETIME, _('One-Time snippet')),
|
||||||
)
|
)
|
||||||
|
|
||||||
secret_id = models.CharField(
|
secret_id = models.CharField(
|
||||||
_(u'Secret ID'), max_length=255, blank=True, null=True, unique=True)
|
_('Secret ID'), max_length=255, blank=True, null=True, unique=True)
|
||||||
content = models.TextField(_(u'Content'))
|
content = models.TextField(_('Content'))
|
||||||
lexer = models.CharField(
|
lexer = models.CharField(
|
||||||
_(u'Lexer'), max_length=30, default=highlight.LEXER_DEFAULT)
|
_('Lexer'), max_length=30, default=highlight.LEXER_DEFAULT)
|
||||||
published = models.DateTimeField(
|
published = models.DateTimeField(
|
||||||
_(u'Published'), auto_now_add=True)
|
_('Published'), auto_now_add=True)
|
||||||
expire_type = models.PositiveSmallIntegerField(
|
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(
|
expires = models.DateTimeField(
|
||||||
_(u'Expires'), blank=True, null=True)
|
_('Expires'), blank=True, null=True)
|
||||||
view_count = models.PositiveIntegerField(
|
view_count = models.PositiveIntegerField(
|
||||||
_('View count'), default=0)
|
_('View count'), default=0)
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
|
|
|
@ -244,7 +244,7 @@ class SnippetAPITestCase(TestCase):
|
||||||
"""
|
"""
|
||||||
Leading Whitespace is retained in the db.
|
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.client.post(self.api_url, {'content': content})
|
||||||
self.assertEqual(Snippet.objects.all()[0].content, content)
|
self.assertEqual(Snippet.objects.all()[0].content, content)
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class SnippetTestCase(TestCase):
|
||||||
the snippet is considered as spam. We let the user know its spam.
|
the snippet is considered as spam. We let the user know its spam.
|
||||||
"""
|
"""
|
||||||
data = self.valid_form_data()
|
data = self.valid_form_data()
|
||||||
data['title'] = u'Any content'
|
data['title'] = 'Any content'
|
||||||
response = self.client.post(self.new_url, data, follow=True)
|
response = self.client.post(self.new_url, data, follow=True)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(Snippet.objects.count(), 0)
|
self.assertEqual(Snippet.objects.count(), 0)
|
||||||
|
@ -212,8 +212,8 @@ class SnippetTestCase(TestCase):
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# XSS and correct escaping
|
# XSS and correct escaping
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
XSS_ORIGINAL = u'<script>hello</script>'
|
XSS_ORIGINAL = '<script>hello</script>'
|
||||||
XSS_ESCAPED = u'<script>hello</script>'
|
XSS_ESCAPED = '<script>hello</script>'
|
||||||
|
|
||||||
def test_xss_text_lexer(self):
|
def test_xss_text_lexer(self):
|
||||||
# Simple 'text' lexer
|
# Simple 'text' lexer
|
||||||
|
@ -361,7 +361,7 @@ class SnippetTestCase(TestCase):
|
||||||
"""
|
"""
|
||||||
Leading Whitespace is retained in the db.
|
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)
|
data = self.valid_form_data(content=content)
|
||||||
self.client.post(self.new_url, data, follow=True)
|
self.client.post(self.new_url, data, follow=True)
|
||||||
self.assertEqual(Snippet.objects.all()[0].content, content)
|
self.assertEqual(Snippet.objects.all()[0].content, content)
|
||||||
|
|
|
@ -205,16 +205,16 @@ class AboutView(TemplateView):
|
||||||
|
|
||||||
def _format_default(s):
|
def _format_default(s):
|
||||||
"""The default response is the snippet URL wrapped in quotes."""
|
"""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):
|
def _format_url(s):
|
||||||
"""The `url` format returns the snippet URL, no quotes, but a linebreak after."""
|
"""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):
|
def _format_json(s):
|
||||||
"""The `json` format export."""
|
"""The `json` format export."""
|
||||||
return json.dumps({
|
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,
|
'content': s.content,
|
||||||
'lexer': s.lexer,
|
'lexer': s.lexer,
|
||||||
})
|
})
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
long_description = u'\n\n'.join((
|
long_description = '\n\n'.join((
|
||||||
open('README.rst').read(),
|
open('README.rst').read(),
|
||||||
open('CHANGELOG').read()
|
open('CHANGELOG').read()
|
||||||
))
|
))
|
||||||
|
@ -23,7 +23,6 @@ setup(
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'Programming Language :: Python :: 2',
|
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Framework :: Django',
|
'Framework :: Django',
|
||||||
],
|
],
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -3,7 +3,7 @@ toxworkdir=/tmp/tox/dpaste
|
||||||
skip_missing_interpreters=True
|
skip_missing_interpreters=True
|
||||||
envlist=
|
envlist=
|
||||||
coverage_setup
|
coverage_setup
|
||||||
py{27,34,35,36}-django-{111}
|
py{34,35,36}-django-{111}
|
||||||
py{34,35,36}-django-{20}
|
py{34,35,36}-django-{20}
|
||||||
coverage_report
|
coverage_report
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue