diff --git a/bak/__init__.py b/bak/__init__.py index 52798a8..293adcf 100644 --- a/bak/__init__.py +++ b/bak/__init__.py @@ -1 +1 @@ -BAK_VERSION = "0.2.0a1" +BAK_VERSION = "0.2.1a1" diff --git a/bak/configuration/__init__.py b/bak/configuration/__init__.py index 90046c1..cd8aeb2 100644 --- a/bak/configuration/__init__.py +++ b/bak/configuration/__init__.py @@ -3,6 +3,7 @@ from pathlib import Path from re import sub +from shutil import copy2 from config import Config, KeyNotFoundError @@ -50,13 +51,15 @@ def __init__(self): self.config_dir = Path("~/.config").expanduser().resolve() self.config_file = self.config_dir / 'bak.cfg' + if not self.config_file.exists(): + copy2(self.config_dir / 'bak.cfg.default', self.config_file) _cfg = Config(str(self.config_file)) reload = False for cfg_value in self.DEFAULT_VALUES: if cfg_value not in _cfg.as_dict(): - with open(self.config_file, 'w') as _file: - _file.write( + with open(self.config_file, 'a') as _file: + _file.writelines( f"{cfg_value}: {self.DEFAULT_VALUES[cfg_value]}\n") _file.close() reload = True diff --git a/setup.py b/setup.py index 770d1d3..7fd9453 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ 'rich==9.1.0'] setup(name='bak', - version='0.2.0a1', + version='0.2.1a1', description='the .bak manager', author='ChanceNCounter', author_email='ChanceNCounter@icloud.com', @@ -28,6 +28,11 @@ config_dir = os.path.expanduser("~/.config") config_file = os.path.join(config_dir, 'bak.cfg') +default_config = os.path.join(config_dir, 'bak.cfg.default') if not os.path.exists(config_file): copy2('bak/default.cfg', config_file) + +if not os.path.exists(default_config): + copy2('bak/default.cfg', default_config) +