From 69e7d7a0de5bf1e6a445a244db5a5c7cd8385e27 Mon Sep 17 00:00:00 2001 From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:20:40 +0100 Subject: [PATCH] create utils module --- src/utils/__init__.py | 2 ++ src/utils/blob.py | 9 +++++++++ src/utils/pickles.py | 6 ++++++ src/utils/temp.py | 4 ++++ 4 files changed, 21 insertions(+) create mode 100644 src/utils/__init__.py create mode 100644 src/utils/blob.py create mode 100644 src/utils/pickles.py create mode 100644 src/utils/temp.py diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..bcfb57c --- /dev/null +++ b/src/utils/__init__.py @@ -0,0 +1,2 @@ +from .pickles import load_pickle, dump_pickle +from .blob import create_blob \ No newline at end of file diff --git a/src/utils/blob.py b/src/utils/blob.py new file mode 100644 index 0000000..a484123 --- /dev/null +++ b/src/utils/blob.py @@ -0,0 +1,9 @@ +def create_blob(file): + """ + Creates a blob from a file. + """ + with open(file, "rb") as f: + blob = f.read() + return blob + + diff --git a/src/utils/pickles.py b/src/utils/pickles.py new file mode 100644 index 0000000..ffb57d3 --- /dev/null +++ b/src/utils/pickles.py @@ -0,0 +1,6 @@ +import pickle + +def load_pickle(data): + return pickle.loads(data) +def dump_pickle(data): + return pickle.dumps(data) diff --git a/src/utils/temp.py b/src/utils/temp.py new file mode 100644 index 0000000..59eaa09 --- /dev/null +++ b/src/utils/temp.py @@ -0,0 +1,4 @@ +template = "{{sap{}_prof}} ({{sap_{}_name}})" +result = "\n".join(template.format(i, i) for i in range(1, 201)) + +print(result)