From db723bbd4832c9901363586f08543e43ef7ffa4e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 26 Jan 2017 22:33:34 +0300 Subject: refactoring Context managers everywhere! --- vk/tracking/db/backend/csv.py | 12 ------------ vk/tracking/db/backend/log.py | 6 ------ vk/tracking/db/backend/null.py | 16 ++-------------- 3 files changed, 2 insertions(+), 32 deletions(-) (limited to 'vk/tracking/db/backend') diff --git a/vk/tracking/db/backend/csv.py b/vk/tracking/db/backend/csv.py index f20c617..e607774 100644 --- a/vk/tracking/db/backend/csv.py +++ b/vk/tracking/db/backend/csv.py @@ -14,12 +14,6 @@ class Writer: self._fd = fd self._writer = csv.writer(fd, lineterminator='\n') - def __enter__(self): - return self - - def __exit__(self, *args): - pass - def on_initial_status(self, user): self._write_record(user) self._fd.flush() @@ -47,12 +41,6 @@ class Reader(Iterable): def __init__(self, fd): self._reader = csv.reader(fd) - def __enter__(self): - return self - - def __exit__(self, *args): - pass - def __iter__(self): return map(Reader._record_from_row, self._reader) diff --git a/vk/tracking/db/backend/log.py b/vk/tracking/db/backend/log.py index 6eebc35..f248d65 100644 --- a/vk/tracking/db/backend/log.py +++ b/vk/tracking/db/backend/log.py @@ -15,12 +15,6 @@ class Writer: datefmt='%Y-%m-%d %H:%M:%S')) self._logger.addHandler(handler) - def __enter__(self): - return self - - def __exit__(self, *args): - pass - def info(self, msg): self._logger.info(msg) diff --git a/vk/tracking/db/backend/null.py b/vk/tracking/db/backend/null.py index 6454f84..3cdb41e 100644 --- a/vk/tracking/db/backend/null.py +++ b/vk/tracking/db/backend/null.py @@ -6,13 +6,7 @@ from collections.abc import Iterable class Writer: - def __init__(self, fd): - pass - - def __enter__(self): - return self - - def __exit__(self, *args): + def __init__(self): pass def on_initial_status(self, user): @@ -25,13 +19,7 @@ class Writer: pass class Reader(Iterable): - def __init__(self, fd): - pass - - def __enter__(self): - return self - - def __exit__(self, *args): + def __init__(self): pass def __iter__(self): -- cgit v1.2.3