aboutsummaryrefslogtreecommitdiff
path: root/gn3/file_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/file_utils.py')
-rw-r--r--gn3/file_utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/gn3/file_utils.py b/gn3/file_utils.py
index d9301bb..cda4f2b 100644
--- a/gn3/file_utils.py
+++ b/gn3/file_utils.py
@@ -3,6 +3,8 @@ import hashlib
import json
import os
import shutil
+import random
+import string
import tarfile
from functools import partial
@@ -51,6 +53,12 @@ def jsonfile_to_dict(json_file: str) -> Dict:
raise FileNotFoundError
+def generate_random_n_string(n_length: int) -> str:
+ """Generate a random string that is N chars long"""
+ return ''.join(random.choice(string.ascii_uppercase + string.digits)
+ for _ in range(n_length))
+
+
def extract_uploaded_file(gzipped_file, target_dir: str) -> Dict:
"""Get the (directory) hash of extracted contents of GZIPPED_FILE; and move
contents to TARGET_DIR/<dir-hash>.