summaryrefslogtreecommitdiff
path: root/src/pyssg/utils.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-04-17 02:13:36 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-04-17 02:13:36 -0600
commit3c0691df1b7ff1fd04e22ab6055e84cc2137504e (patch)
treedded20edb6c37f2b6904447684db693fcddf16a7 /src/pyssg/utils.py
parentf203d11cff37d6809396d0ea39bf53abe9bad182 (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.py28
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)