aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-01 12:57:47 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commitff29ce04a1f10af819770ccafd347daaba6b2bf7 (patch)
tree567efcca801772847edf49b60ecc5faf42efe76e /gn3
parent52e3569cca6b24d1318034f5ab004795e70135f5 (diff)
downloadgenenetwork3-ff29ce04a1f10af819770ccafd347daaba6b2bf7.tar.gz
Move "generate_random_n_string" to file_utils
* gn3/computations/gemma.py (generaten_random_n_string): Move to... * gn3/file_utils.py: ... here.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/computations/gemma.py7
-rw-r--r--gn3/file_utils.py8
2 files changed, 8 insertions, 7 deletions
diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py
index 528f888..7ee70b0 100644
--- a/gn3/computations/gemma.py
+++ b/gn3/computations/gemma.py
@@ -1,7 +1,5 @@
"""Procedures related gemma computations"""
import os
-import random
-import string
from base64 import b64encode
from hashlib import md5
@@ -11,11 +9,6 @@ from typing import Optional
from typing import ValuesView
from gn3.commands import compose_gemma_cmd
-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 generate_hash_of_string(unhashed_str: str) -> str:
"""Given an UNHASHED_STRING, generate it's md5 hash while removing the '==' at
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>.