From e48e87811b518e1c08538fc5d24915a93baa7542 Mon Sep 17 00:00:00 2001 From: Matt Hauff Date: Tue, 17 Aug 2021 09:42:14 -0700 Subject: [PATCH] Paginate hex files every 80 characters --- clvm_tools/clvmc.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clvm_tools/clvmc.py b/clvm_tools/clvmc.py index c72d625..5485276 100644 --- a/clvm_tools/clvmc.py +++ b/clvm_tools/clvmc.py @@ -30,7 +30,7 @@ def compile_clvm(input_path, output_path, search_paths=[]): hex = result.as_bin().hex() with open(output_path, "w") as f: - f.write(hex) + f.write(insert_newlines(hex)) f.write("\n") else: log.info("skipping %s, compiled recently" % input_path) @@ -48,3 +48,9 @@ def find_files(path=""): compile_clvm(full_path, target) r.append(target) return r + +def insert_newlines(string, every=80): + lines = [] + for i in range(0, len(string), every): + lines.append(string[i:i+every]) + return '\n'.join(lines)