Skip to content

Commit

Permalink
Drop dependency on 'six'.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Dec 29, 2014
1 parent f886a6b commit 23ef7a7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,8 @@ Changes
4.1.0 (unreleased)
------------------

- Drop dependency on ``six``.

- Add support for Python 3.4.

- Add support for testing on Travis.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -58,7 +58,7 @@ def read(*rnames):
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope',],
install_requires=['setuptools', 'six'],
install_requires=['setuptools'],
test_suite='zope.structuredtext.tests.test_suite',
include_package_data=True,
zip_safe=False,
Expand Down
17 changes: 10 additions & 7 deletions src/zope/structuredtext/document.py
Expand Up @@ -13,7 +13,6 @@
""" Structured text document parser
"""
import re
import six

from zope.structuredtext.stletters import letters
from zope.structuredtext.stletters import literal_punc
Expand Down Expand Up @@ -41,6 +40,10 @@
from zope.structuredtext.stng import StructuredTextXref
from zope.structuredtext.stng import structurize

try:
string_types = (unicode, str)
except NameError: # pragma: NO COVER Py3k
string_types = (str,)

__metaclass__ = type

Expand Down Expand Up @@ -84,7 +87,7 @@ class Document:
]

def __call__(self, doc):
if isinstance(doc, six.string_types):
if isinstance(doc, string_types):
doc = structurize(doc)
doc.setSubparagraphs(self.color_paragraphs(
doc.getSubparagraphs()))
Expand All @@ -108,7 +111,7 @@ def parse(self, raw_string, text_type, type=type):

tmp = [] # the list to be returned if raw_string is split

if isinstance(text_type, six.string_types):
if isinstance(text_type, string_types):
text_type = getattr(self, text_type)

while True:
Expand All @@ -121,7 +124,7 @@ def parse(self, raw_string, text_type, type=type):
if start:
tmp.append(raw_string[:start])

if isinstance(t, six.string_types):
if isinstance(t, string_types):
# if we get a string back, add it to text to be parsed
raw_string = t + raw_string[end:len(raw_string)]
else:
Expand Down Expand Up @@ -151,13 +154,13 @@ def color_text(self, text, types=None):

for text_type in types:

if isinstance(text, six.string_types):
if isinstance(text, string_types):
text = self.parse(text, text_type)
elif isinstance(text, list): #Waaaa
result = []

for s in text:
if isinstance(s, six.string_types):
if isinstance(s, string_types):
s = self.parse(s, text_type)
if isinstance(s, list):
result.extend(s)
Expand All @@ -180,7 +183,7 @@ def color_text(self, text, types=None):

def color_paragraphs(self, raw_paragraphs,
type=type, sequence_types=(tuple, list),
sts=six.string_types):
sts=string_types):
result=[]
for paragraph in raw_paragraphs:
if paragraph.getNodeName() != 'StructuredTextParagraph':
Expand Down
5 changes: 4 additions & 1 deletion src/zope/structuredtext/stdom.py
Expand Up @@ -12,7 +12,10 @@
##############################################################################
"""DOM implementation in StructuredText: read-only methods
"""
from six import string_types
try:
string_types = (unicode, str)
except NameError: # pragma: NO COVER Py3k
string_types = (str,)

__metaclass__ = type

Expand Down
8 changes: 3 additions & 5 deletions src/zope/structuredtext/tests.py
@@ -1,6 +1,4 @@
from __future__ import print_function
from __future__ import print_function
from __future__ import print_function
##############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors.
Expand Down Expand Up @@ -76,9 +74,9 @@ def _test(self, stxtxt, expected):
doc = DocumentWithImages()(doc)
output = HTMLWithImages()(doc, level=1)
if not expected in output:
print("Text: ", stxtxt.encode('utf-8'))
print("Converted:", output.encode('utf-8'))
print("Expected: ", expected.encode('utf-8'))
print("Text: %s" % stxtxt.encode('utf-8'))
print("Converted: %s" % output.encode('utf-8'))
print("Expected: %s" % expected.encode('utf-8'))
self.fail("'%s' not in result" % expected)

def testUnderline(self):
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
@@ -1,9 +1,9 @@
[tox]
envlist =
# Pending normalization of HTML output for regressions.
# py26,py27,py33,py34,pypy,pypy3
py26,py27,py33,py34

[testenv]
commands =
python setup.py test -q
deps =
six

0 comments on commit 23ef7a7

Please sign in to comment.