aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-09-09 20:31:38 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-09-09 20:34:33 +0300
commitdee634e884d576ab84e0ac74843e67f930b9fb31 (patch)
tree70d0b85e0e9682f9274027ff1bac8820f3554715
parentTravis: output DB by track_status.py (diff)
downloadvk-scripts-dee634e884d576ab84e0ac74843e67f930b9fb31.tar.gz
vk-scripts-dee634e884d576ab84e0ac74843e67f930b9fb31.zip
work around Python 3.4 csv incompatibility
-rw-r--r--bin/utils/io.py8
-rw-r--r--vk/tracking/db/io.py8
2 files changed, 16 insertions, 0 deletions
diff --git a/bin/utils/io.py b/bin/utils/io.py
index 2cd3667..04baa6a 100644
--- a/bin/utils/io.py
+++ b/bin/utils/io.py
@@ -20,7 +20,15 @@ class FileWriterCSV:
def __init__(self, fd=sys.stdout):
self._writer = csv.writer(fd, lineterminator='\n')
+ @staticmethod
+ def _convert_row_old_python(row):
+ if isinstance(row, list) or isinstance(row, tuple):
+ return row
+ return list(row)
+
def write_row(self, row):
+ if sys.version_info < (3, 5):
+ row = self._convert_row_old_python(row)
self._writer.writerow(row)
@contextmanager
diff --git a/vk/tracking/db/io.py b/vk/tracking/db/io.py
index 487a136..37d9c53 100644
--- a/vk/tracking/db/io.py
+++ b/vk/tracking/db/io.py
@@ -12,7 +12,15 @@ class FileWriterCSV:
self._fd = fd
self._writer = csv.writer(fd, lineterminator='\n')
+ @staticmethod
+ def _convert_row_old_python(row):
+ if isinstance(row, list) or isinstance(row, tuple):
+ return row
+ return list(row)
+
def write_row(self, row):
+ if sys.version_info < (3, 5):
+ row = self._convert_row_old_python(row)
self._writer.writerow(row)
self._fd.flush()