Browse Source

Started work on the config parser

master
Raphael Roberts 5 years ago
parent
commit
926f42ae6f
  1. 9
      config.yml.sample
  2. 2
      requirements.txt
  3. 1
      setup.py
  4. 23
      tibi_hardlinks/config.py
  5. 0
      tibi_hardlinks/config_parser.py

9
config.yml.sample

@ -0,0 +1,9 @@
input:
backup_paths:
- "/path/to/backup/location"
- "~/tilde/is/supported"
output:
output_root: "/path/must/be/on/the/same/filesystem"
customization:
time_format: "%Y-%m-%d_%H-%M-%S"

2
requirements.txt

@ -1,2 +1,4 @@
pytz
python-dateutil
PyYAML
appdirs

1
setup.py

@ -11,4 +11,5 @@ setup(
author="Raphael Roberts",
author_email="raphael.roberts48@gmail.com",
packages=find_packages(),
data_files=[("", ["config.yml.sample"])],
)

23
tibi_hardlinks/config.py

@ -0,0 +1,23 @@
import appdirs as _appdirs
import os
import shutil
import yaml
def ensure_directory_exists(path):
os.makedirs(path, exist_ok=True)
return path
appdirs = _appdirs.AppDirs("tibi_hardlinks")
CONFIG_DIR = ensure_directory_exists(appdirs.user_config_dir)
CACHE_DIR = ensure_directory_exists(appdirs.user_cache_dir)
CONFIG_FILE_PATH = os.path.join(CONFIG_DIR, "config.yml")
PACKAGE_ROOT = os.path.dirname(os.path.abspath(__file__))
if not os.path.exists(CONFIG_FILE_PATH):
shutil.copy(os.path.join(PACKAGE_ROOT, "config.yml"), CONFIG_FILE_PATH)
with open(CONFIG_FILE_PATH, "r") as config_file:
CONFIG_DATA = yaml.load(config_file)

0
tibi_hardlinks/config_parser.py

Loading…
Cancel
Save