From ff29ce04a1f10af819770ccafd347daaba6b2bf7 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 1 Mar 2021 12:57:47 +0300 Subject: Move "generate_random_n_string" to file_utils * gn3/computations/gemma.py (generaten_random_n_string): Move to... * gn3/file_utils.py: ... here. --- gn3/file_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gn3/file_utils.py') 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/. -- cgit v1.2.3