From a8c1303e7f382609ea1acae894c2d7682fdad01b Mon Sep 17 00:00:00 2001 From: Bill Zorn Date: Wed, 2 Dec 2015 15:27:18 -0800 Subject: [PATCH] now also cleans up the dumps --- scripts/collect_checkpoints.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/collect_checkpoints.py b/scripts/collect_checkpoints.py index b7a9e95..95df0f0 100755 --- a/scripts/collect_checkpoints.py +++ b/scripts/collect_checkpoints.py @@ -3,6 +3,13 @@ import sys import os import shutil +def cleanup_dump(dumpstr): + cardfrags = dumpstr.split('\n\n') + if len(cardfrags) < 4: + return '' + else: + return '\n\n'.join(cardfrags[2:-1]) + '\n\n' + def identify_checkpoints(basedir, ident): cp_infos = [] for path in os.listdir(basedir): @@ -46,8 +53,10 @@ def process_dir(basedir, targetdir, ident, copy_cp = False, verbose = False): tdpath = os.path.join(targetdir, dname) tcpath = os.path.join(targetdir, cname) if verbose: - print(' cp ' + dpath + ' ' + tdpath) - shutil.copy(dpath, tdpath) + print(' cpx ' + dpath + ' ' + tdpath) + with open(dpath, 'rt') as infile: + with open(tdpath, 'wt') as outfile: + outfile.write(cleanup_dump(infile.read())) if copy_cp: if os.path.isfile(cpath): if verbose: