summaryrefslogtreecommitdiff
path: root/src/pyssg/utils.py
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-04-23 21:49:53 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-04-23 21:49:53 -0600
commit8a0b1d2d9f9629e4a186549b134ebd6b80a5d71b (patch)
tree287943581199328a91716faddaa14f7e4ad22088 /src/pyssg/utils.py
parentdfc3e6db921815416b8edc5892b2a7adfc677a25 (diff)
add proper var expansion from config filev0.7.1
Diffstat (limited to 'src/pyssg/utils.py')
-rw-r--r--src/pyssg/utils.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/pyssg/utils.py b/src/pyssg/utils.py
index a41249a..4b525cf 100644
--- a/src/pyssg/utils.py
+++ b/src/pyssg/utils.py
@@ -74,13 +74,6 @@ def copy_file(src: str, dst: str) -> None:
log.info('file "%s" already exists, ignoring', dst)
-def sanity_check_path(path: str) -> None:
- if '$' in path:
- log.error('"$" character found in path "%s";'
- ' could be due to non-existant env var.', path)
- sys.exit(1)
-
-
# as seen in SO: https://stackoverflow.com/a/1131238
def get_checksum(path: str) -> str:
log.debug('calculating md5 checksum for "%s"', path)
@@ -89,4 +82,16 @@ def get_checksum(path: str) -> str:
while chunk := f.read(4096):
file_hash.update(chunk)
- return file_hash.hexdigest() \ No newline at end of file
+ return file_hash.hexdigest()
+
+
+def get_expanded_path(path: str) -> None:
+ log.debug('expanding path "%s"', path)
+ expanded_path: str = os.path.normpath(os.path.expandvars(path))
+ if '$' in expanded_path:
+ log.error('"$" character found in expanded path "%s";'
+ ' could be due to non-existant env var.', expanded_path)
+ sys.exit(1)
+ log.debug('expanded path "%s" to "%s"', path, expanded_path)
+
+ return expanded_path