Do not flush on exit if there is no file specified

This commit is contained in:
Kevin 2020-07-24 14:41:59 -05:00
parent a7f8dd31e2
commit 2067a554fb
3 changed files with 15 additions and 11 deletions

View File

@ -2,11 +2,15 @@
This project uses Semantic Versioning This project uses Semantic Versioning
## 0.3.1
* Do not register exit flush if there is no storage file specified
## 0.3.0 ## 0.3.0
Added get_raw_json * Added get_raw_json
Improved code formatting * Improved code formatting
Switched to setuptools * Switched to setuptools
## 0.2.0 ## 0.2.0
@ -14,14 +18,14 @@ Added automatic creation of path for file writing
## 0.1.1 ## 0.1.1
Added: ### Added:
flush_on_exit: default argument to write to file on python close * flush_on_exit: default argument to write to file on python close
changelog file * changelog file
Changed: ### Changed:
Readme to correctly reflect public function count * Readme to correctly reflect public function count
## 0.0.1 ## 0.0.1

View File

@ -47,7 +47,7 @@ class DeadSimpleKV:
self._last_refresh = temp_time # time last refreshed from disk self._last_refresh = temp_time # time last refreshed from disk
self._last_flush = temp_time # time last flushed to disk self._last_flush = temp_time # time last flushed to disk
if not file_path is None: if file_path is not None:
abs_path = os.path.dirname(os.path.abspath(file_path)) abs_path = os.path.dirname(os.path.abspath(file_path))
if not os.path.exists(abs_path): if not os.path.exists(abs_path):
os.makedirs(abs_path) os.makedirs(abs_path)
@ -58,7 +58,7 @@ class DeadSimpleKV:
except TypeError: except TypeError:
pass pass
if flush_on_exit: if flush_on_exit and file_path:
atexit.register(self.flush) atexit.register(self.flush)
def get(self, key): def get(self, key):

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup(name='deadsimplekv', setup(name='deadsimplekv',
version='0.3.0', version='0.3.1',
description='Very simple key-value store for Python', description='Very simple key-value store for Python',
author='Kevin Froman', author='Kevin Froman',
author_email='beardog@mailbox.org', author_email='beardog@mailbox.org',