summaryrefslogtreecommitdiff
path: root/trove/common/stream_codecs.py
diff options
context:
space:
mode:
authorwangzihao <wangzihao@yovole.com>2020-10-16 10:40:22 +0800
committerwangzihao <wangzihao@yovole.com>2020-10-16 10:40:22 +0800
commite9541846936cec27b70f3975eba837cf938af21d (patch)
tree5f707da6fc9f7e61eeb888d1353116d464446b17 /trove/common/stream_codecs.py
parent9e2515aad353c0ad6ced3558c6cc0fcd6d478fff (diff)
downloadtrove-e9541846936cec27b70f3975eba837cf938af21d.tar.gz
Remove six usage and basestring check
Remove basestring check. Remove six Replace the following items with Python 3 style code. - six.string_types - six.int2byte - six.indexbytes - six.add_metaclass - six.StringIO - six.text_type - six.integer_types - six.binary_type - six.BytesIO - six.reraise Change-Id: I4fb9033d152963c504ceb4d5c4d08f934ee4accb
Diffstat (limited to 'trove/common/stream_codecs.py')
-rw-r--r--trove/common/stream_codecs.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/trove/common/stream_codecs.py b/trove/common/stream_codecs.py
index 824273d5..ab5a60b7 100644
--- a/trove/common/stream_codecs.py
+++ b/trove/common/stream_codecs.py
@@ -21,7 +21,6 @@ import io
import re
import sys
-import six
import xmltodict
import yaml
@@ -74,7 +73,7 @@ class StringConverter(object):
# Return known mappings and quoted strings right away.
if value in self._object_mappings:
return self._object_mappings[value]
- elif (isinstance(value, six.string_types) and
+ elif (isinstance(value, str) and
re.match("^'(.*)'|\"(.*)\"$", value)):
return value
@@ -84,8 +83,7 @@ class StringConverter(object):
return value
-@six.add_metaclass(abc.ABCMeta)
-class StreamCodec(object):
+class StreamCodec(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def serialize(self, data):
@@ -202,7 +200,7 @@ class IniCodec(StreamCodec):
def serialize(self, dict_data):
parser = self._init_config_parser(dict_data)
- output = six.StringIO()
+ output = io.StringIO()
parser.write(output)
return output.getvalue()
@@ -217,8 +215,8 @@ class IniCodec(StreamCodec):
for s in parser.sections()}
def _pre_parse(self, stream):
- buf = six.StringIO()
- for line in six.StringIO(stream):
+ buf = io.StringIO()
+ for line in io.StringIO(stream):
# Ignore commented lines.
if not line.startswith(self._comment_markers):
# Strip leading and trailing whitespaces from each line.
@@ -297,7 +295,7 @@ class PropertiesCodec(StreamCodec):
self._unpack_singletons = unpack_singletons
def serialize(self, dict_data):
- output = six.StringIO()
+ output = io.StringIO()
writer = csv.writer(output, delimiter=self._delimiter,
quoting=self.QUOTING_MODE,
strict=self.STRICT_MODE,
@@ -309,7 +307,7 @@ class PropertiesCodec(StreamCodec):
return output.getvalue()
def deserialize(self, stream):
- reader = csv.reader(six.StringIO(stream),
+ reader = csv.reader(io.StringIO(stream),
delimiter=self._delimiter,
quoting=self.QUOTING_MODE,
strict=self.STRICT_MODE,