1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
--- a/airspeed/__init__.py
+++ b/airspeed/__init__.py
@@ -6,7 +6,18 @@
import string
import sys
-import six
+import io
+
+def six_reraise(tp, value, tb=None):
+ try:
+ if value is None:
+ value = tp()
+ if value.__traceback__ is not tb:
+ raise value.with_traceback(tb)
+ raise value
+ finally:
+ value = None
+ tb = None
__all__ = [
'Template',
@@ -207,14 +218,14 @@
return template
-class StoppableStream(six.StringIO):
+class StoppableStream(io.StringIO):
def __init__(self, buf=''):
self.stop = False
- six.StringIO.__init__(self, buf)
+ io.StringIO.__init__(self, buf)
def write(self, s):
if not self.stop:
- six.StringIO.write(self, s)
+ io.StringIO.write(self, s)
###############################################################################
@@ -358,7 +369,7 @@
raise
except:
exc_info = sys.exc_info()
- six.reraise(TemplateExecutionError,
+ six_reraise(TemplateExecutionError,
TemplateExecutionError(self, exc_info), exc_info[2])
@@ -621,7 +632,7 @@
# If list make sure index is an integer
if isinstance(
result, list) and not isinstance(
- array_index, six.integer_types):
+ array_index, int):
raise ValueError(
"expected integer for array index, got '%s'" %
(array_index))
@@ -760,7 +771,7 @@
if is_string(value):
stream.write(value)
else:
- stream.write(six.text_type(value))
+ stream.write(str(value))
class Null:
--- a/setup.cfg
+++ b/setup.cfg
@@ -24,7 +24,6 @@
[options]
install_requires =
- six
cachetools
packages = find:
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -17,7 +17,7 @@
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import airspeed
-import six
+import io
class TemplateTestCase(TestCase):
@@ -338,7 +338,7 @@
def test_merge_to_stream(self):
template = airspeed.Template('Hello $name!')
- output = six.StringIO()
+ output = io.StringIO()
template.merge_to({"name": "Chris"}, output)
self.assertEqual('Hello Chris!', output.getvalue())
@@ -981,7 +981,7 @@
def __str__(self):
return self.value
value = Clazz(u'£12,000')
- self.assertEqual(six.text_type(value), template.merge(locals()))
+ self.assertEqual(str(value), template.merge(locals()))
def test_can_define_macros_in_parsed_files(self):
class Loader:
|