summaryrefslogtreecommitdiff
path: root/src/pyssg/utils.py
diff options
context:
space:
mode:
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)