diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-01-29 07:49:42 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-01-29 07:49:42 +0300 |
commit | 6fec9eefe56b9e476d5faf0d57dc2a80b703c9d6 (patch) | |
tree | e4e71aefba74780e63792553676206e14688719c /vk/tracking/db/io.py | |
parent | add connection errors to the db logger (diff) | |
download | vk-scripts-6fec9eefe56b9e476d5faf0d57dc2a80b703c9d6.tar.gz vk-scripts-6fec9eefe56b9e476d5faf0d57dc2a80b703c9d6.zip |
don't overwrite database files
Diffstat (limited to '')
-rw-r--r-- | vk/tracking/db/io.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/vk/tracking/db/io.py b/vk/tracking/db/io.py index 805334d..d280634 100644 --- a/vk/tracking/db/io.py +++ b/vk/tracking/db/io.py @@ -36,8 +36,12 @@ def _open_file(path=None, default=None, **kwargs): if fd is not default: fd.close() -def open_output_text_file(path=None): - return _open_file(path, default=sys.stdout, mode='w', encoding='utf-8') +_DEFAULT_ENCODING = 'utf-8' + +def open_output_text_file(path=None, mode='w'): + return _open_file(path, default=sys.stdout, mode=mode, + encoding=_DEFAULT_ENCODING) def open_input_text_file(path=None): - return _open_file(path, default=sys.stdin, mode='r', encoding='utf-8') + return _open_file(path, default=sys.stdin, mode='r', + encoding=_DEFAULT_ENCODING) |