From f39f18c94060642859900bdb04cb4df2164bc8b4 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 18 Jun 2016 02:22:36 +0300 Subject: put format-specific db writers/readers together --- vk/utils/tracking/db/reader/__init__.py | 5 ----- vk/utils/tracking/db/reader/csv.py | 31 ------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 vk/utils/tracking/db/reader/__init__.py delete mode 100644 vk/utils/tracking/db/reader/csv.py (limited to 'vk/utils/tracking/db/reader') diff --git a/vk/utils/tracking/db/reader/__init__.py b/vk/utils/tracking/db/reader/__init__.py deleted file mode 100644 index 330d5a8..0000000 --- a/vk/utils/tracking/db/reader/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 2016 Egor Tensin -# This file is licensed under the terms of the MIT License. -# See LICENSE.txt for details. - -__all__ = 'csv', diff --git a/vk/utils/tracking/db/reader/csv.py b/vk/utils/tracking/db/reader/csv.py deleted file mode 100644 index 9d4e7dc..0000000 --- a/vk/utils/tracking/db/reader/csv.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2016 Egor Tensin -# This file is licensed under the terms of the MIT License. -# See LICENSE.txt for details. - -from collections.abc import Iterable -import csv - -from ..record import Record -from ..timestamp import Timestamp - -class Reader(Iterable): - def __init__(self, path): - self._fd = open(path) - self._reader = csv.reader(self._fd) - - def __enter__(self): - self._fd.__enter__() - return self - - def __exit__(self, *args): - self._fd.__exit__(*args) - - def __iter__(self): - return map(Reader._record_from_row, self._reader) - - @staticmethod - def _record_from_row(row): - record = Record(Timestamp.from_string(row[0])) - for i in range(len(Record.FIELDS)): - record[Record.FIELDS[i]] = row[i + 1] - return record -- cgit v1.2.3