summaryrefslogtreecommitdiff
path: root/subplot/data.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-08 08:51:14 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-08 10:43:22 +0200
commitf75eb2433ac790891eaeb07248cf98d525cd5a13 (patch)
tree07930c76003e0495f384e626b7fcc91dbb031816 /subplot/data.py
parent2e92cbb0aefbde6a015c67e3886514c8af61cb5b (diff)
downloadobnam2-f75eb2433ac790891eaeb07248cf98d525cd5a13.tar.gz
refactor: move functions around so that data stuff is in data.yaml
Diffstat (limited to 'subplot/data.py')
-rw-r--r--subplot/data.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/subplot/data.py b/subplot/data.py
index a1b9032..c4cb0a7 100644
--- a/subplot/data.py
+++ b/subplot/data.py
@@ -1,7 +1,6 @@
import logging
import os
import random
-import subprocess
def create_file_with_random_data(ctx, filename=None):
@@ -14,5 +13,32 @@ def create_file_with_random_data(ctx, filename=None):
f.write(data)
-def live_and_restored_data_match(ctx, live=None, restore=None):
- subprocess.check_call(["diff", "-rq", f"{live}/.", f"{restore}/{live}/."])
+def create_manifest_of_live(ctx, dirname=None, manifest=None):
+ _create_manifest_of_directory(ctx, dirname=dirname, manifest=manifest)
+
+
+def create_manifest_of_restored(ctx, dirname=None, restored=None, manifest=None):
+ _create_manifest_of_directory(
+ ctx, dirname=os.path.join(restored, "./" + dirname), manifest=manifest
+ )
+
+
+def _create_manifest_of_directory(ctx, dirname=None, manifest=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_get_exit_code = globals()["runcmd_get_exit_code"]
+ runcmd_get_stdout = globals()["runcmd_get_stdout"]
+
+ runcmd_run(ctx, ["summain", dirname])
+ assert runcmd_get_exit_code(ctx) == 0
+ stdout = runcmd_get_stdout(ctx)
+ open(manifest, "w").write(stdout)
+
+
+def files_match(ctx, first=None, second=None):
+ assert_eq = globals()["assert_eq"]
+
+ f = open(first).read()
+ s = open(first).read()
+ logging.debug(f"files_match: f={f!r}")
+ logging.debug(f"files_match: s={s!r}")
+ assert_eq(f, s)