diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-04-17 02:13:36 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-04-17 02:13:36 -0600 |
commit | 3c0691df1b7ff1fd04e22ab6055e84cc2137504e (patch) | |
tree | dded20edb6c37f2b6904447684db693fcddf16a7 /src/pyssg/utils.py | |
parent | f203d11cff37d6809396d0ea39bf53abe9bad182 (diff) |
refactor config handler and morev0.6.0
Refactored the configuration handling to use configparser; also the argument parser; generally added more 'logging'; updated template resources; and more minor things
Diffstat (limited to 'src/pyssg/utils.py')
-rw-r--r-- | src/pyssg/utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pyssg/utils.py b/src/pyssg/utils.py new file mode 100644 index 0000000..8e5d90e --- /dev/null +++ b/src/pyssg/utils.py @@ -0,0 +1,28 @@ +import os +import sys +import shutil + + +def create_dir(path: str, p: bool=False) -> None: + try: + if p: + os.makedirs(path) + else: + os.mkdir(path) + print(f'created directory "{path}"') + except FileExistsError: + print(f'directory "{path}" already exists') + + +def copy_file(src: str, dst: str) -> None: + if not os.path.exists(dst): + shutil.copy(src, dst) + print(f'copied file "{src}" to "{dst}"') + else: + print(f'"{dst}" already exists') + + +def sanity_check_path(path: str) -> None: + if '$' in path: + print(f'"$" character found in path: "{path}"; could be due to non-existant env var.') + sys.exit(1) |