aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2020-02-12 23:24:23 +0100
committerMartin Vilcans <martin@librador.com>2020-02-12 23:24:23 +0100
commit7c786ef7d69c9b364214e10490183bc207c24e5a (patch)
tree29131ddf119dfa2a7ae96447ff2f3e27a6d94536
parent1f2121726e709c8445ecd793eca89387d5b78145 (diff)
parenteb73207913915be7131256a1ed80d2402ecf6ad6 (diff)
downloadscreenplain-7c786ef7d69c9b364214e10490183bc207c24e5a.tar.gz
Merge branch 'remove-py2'
-rwxr-xr-xbin/test11
-rw-r--r--requirements.txt1
-rw-r--r--screenplain/parsers/fountain.py1
-rw-r--r--screenplain/richstring.py37
-rwxr-xr-xsetup.py1
-rw-r--r--test.py24
-rw-r--r--tests/fdx_test.py2
-rw-r--r--tests/fountain_test.py2
-rw-r--r--tests/richstring_test.py3
9 files changed, 24 insertions, 58 deletions
diff --git a/bin/test b/bin/test
index 4ffcb17..5379c1b 100755
--- a/bin/test
+++ b/bin/test
@@ -1,8 +1,3 @@
-#!/bin/bash
-if [[ $(python -V 2>&1) =~ "Python 2" ]]
-then
- nosetests --nocapture --with-doctest --doctest-tests -I ^test.py $* && \
- pycodestyle --ignore=E402,W504 screenplain tests
-else
- python test.py && pycodestyle --ignore=E402,W504 screenplain tests
-fi
+#!/bin/bash -e
+nosetests --nocapture --with-doctest --doctest-tests
+pycodestyle --ignore=E402,W504 screenplain tests
diff --git a/requirements.txt b/requirements.txt
index 97231be..a818b80 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,4 +2,3 @@ reportlab
unittest2
nose
pycodestyle
-six
diff --git a/screenplain/parsers/fountain.py b/screenplain/parsers/fountain.py
index c2f6d71..7f367aa 100644
--- a/screenplain/parsers/fountain.py
+++ b/screenplain/parsers/fountain.py
@@ -5,7 +5,6 @@
import itertools
from itertools import takewhile
import re
-from six import next
from screenplain.types import (
Slug, Action, Dialog, DualDialog, Transition, Section, PageBreak,
diff --git a/screenplain/richstring.py b/screenplain/richstring.py
index 2fafd9b..3890ecd 100644
--- a/screenplain/richstring.py
+++ b/screenplain/richstring.py
@@ -3,14 +3,13 @@
# http://www.opensource.org/licenses/mit-license.php
import re
-import six
try:
from html import escape as html_escape
except ImportError:
from cgi import escape as html_escape
-_magic_re = re.compile(u'[\ue700-\ue705]')
+_magic_re = re.compile('[\ue700-\ue705]')
def _escape(s):
@@ -35,7 +34,7 @@ class RichString(object):
return ' + '.join(repr(s) for s in self.segments)
def __unicode__(self):
- return ''.join(six.text_type(s) for s in self.segments)
+ return ''.join(str(s) for s in self.segments)
def __str__(self):
return self.__unicode__()
@@ -169,8 +168,8 @@ class Italic(Style):
r'(?!\*)'
)
- start_magic = u'\ue700'
- end_magic = u'\ue701'
+ start_magic = '\ue700'
+ end_magic = '\ue701'
start_html = '<em>'
end_html = '</em>'
@@ -189,8 +188,8 @@ class Bold(Style):
r'(?<=\S)\*\*'
)
- start_magic = u'\ue702'
- end_magic = u'\ue703'
+ start_magic = '\ue702'
+ end_magic = '\ue703'
start_html = '<strong>'
end_html = '</strong>'
@@ -209,8 +208,8 @@ class Underline(Style):
r'(?<=\S)_'
)
- start_magic = u'\ue704'
- end_magic = u'\ue705'
+ start_magic = '\ue704'
+ end_magic = '\ue705'
start_html = '<u>' # TODO: use an actual html5 tag
end_html = '</u>'
@@ -238,7 +237,7 @@ underline = _CreateStyledString((Underline,))
empty_string = RichString()
# A special unicode character to use for a literal '*'
-literal_star = u'\ue706'
+literal_star = '\ue706'
# All styles. Note: order matters! This is the order they are parsed.
all_styles = (Bold, Italic, Underline)
@@ -249,7 +248,7 @@ def _unescape(source):
"literal star" character.
>>> _unescape(r'\*hello\*')
- u'\ue706hello\ue706'
+ '\ue706hello\ue706'
"""
return source.replace('\\*', literal_star)
@@ -258,8 +257,8 @@ def _unescape(source):
def _demagic_literals(text):
r"""Converts "literal star" characters to actual stars: "*"
- >>> _demagic_literals(u'\ue706hello\ue706')
- u'*hello*'
+ >>> _demagic_literals('\ue706hello\ue706')
+ '*hello*'
"""
return text.replace(literal_star, '*')
@@ -268,12 +267,12 @@ def parse_emphasis(source):
"""Parses emphasis markers like * and ** in a string
and returns a RichString object.
- >>> parse_emphasis(u'**hello**')
- (bold)(u'hello')
- >>> parse_emphasis(u'plain')
- (plain)(u'plain')
- >>> parse_emphasis(u'**hello** there')
- (bold)(u'hello') + (plain)(u' there')
+ >>> parse_emphasis('**hello**')
+ (bold)('hello')
+ >>> parse_emphasis('plain')
+ (plain)('plain')
+ >>> parse_emphasis('**hello** there')
+ (bold)('hello') + (plain)(' there')
"""
# Convert escaped characters to magic characters so they aren't parsed
diff --git a/setup.py b/setup.py
index 68ad1c5..1b16e9f 100755
--- a/setup.py
+++ b/setup.py
@@ -15,7 +15,6 @@ setup(
},
license='MIT',
install_requires=[
- 'six',
],
extras_require={
'PDF': 'reportlab'
diff --git a/test.py b/test.py
deleted file mode 100644
index c4e5887..0000000
--- a/test.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""Runs nosetest after preparing the test cases.
-
-Removes the leading u from unicode literals so
-Python 3 doctests won't fail.
-
-"""
-
-from screenplain import richstring
-import re
-
-unicode_literal = re.compile(r'u([\'"])')
-
-for n in (
- 'parse_emphasis',
- '_unescape',
- '_demagic_literals',
-):
- attr = getattr(richstring, n)
- old_doc = getattr(attr, '__doc__')
- new_doc = unicode_literal.sub(r'\1', old_doc)
- setattr(attr, '__doc__', new_doc)
-
-import nose
-nose.main(argv='nosetests --nocapture --with-doctest --doctest-tests'.split())
diff --git a/tests/fdx_test.py b/tests/fdx_test.py
index 497f908..3a3c8f7 100644
--- a/tests/fdx_test.py
+++ b/tests/fdx_test.py
@@ -3,7 +3,7 @@
# http://www.opensource.org/licenses/mit-license.php
from testcompat import TestCase
-from six import StringIO
+from io import StringIO
from screenplain.export.fdx import write_text
from screenplain.richstring import plain, bold, italic
diff --git a/tests/fountain_test.py b/tests/fountain_test.py
index c31cc66..141772a 100644
--- a/tests/fountain_test.py
+++ b/tests/fountain_test.py
@@ -9,7 +9,7 @@ from screenplain.types import (
Slug, Action, Dialog, DualDialog, Transition, Section, PageBreak
)
from screenplain.richstring import plain, italic, empty_string
-from six import StringIO
+from io import StringIO
def parse(lines):
diff --git a/tests/richstring_test.py b/tests/richstring_test.py
index ee42087..82b2af0 100644
--- a/tests/richstring_test.py
+++ b/tests/richstring_test.py
@@ -3,7 +3,6 @@
# http://www.opensource.org/licenses/mit-license.php
from testcompat import TestCase
-import six
from screenplain.richstring import (
RichString, Segment,
Bold, Italic,
@@ -39,7 +38,7 @@ class RichStringOperatorTests(TestCase):
s = bold('Hello') + plain(' there ') + bold('folks')
self.assertEquals(
u'Hello there folks',
- six.text_type(s)
+ str(s)
)
def test_eq(self):