now also cleans up the dumps
This commit is contained in:
parent
34176585b2
commit
a8c1303e7f
1 changed files with 11 additions and 2 deletions
|
@ -3,6 +3,13 @@ import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
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):
|
def identify_checkpoints(basedir, ident):
|
||||||
cp_infos = []
|
cp_infos = []
|
||||||
for path in os.listdir(basedir):
|
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)
|
tdpath = os.path.join(targetdir, dname)
|
||||||
tcpath = os.path.join(targetdir, cname)
|
tcpath = os.path.join(targetdir, cname)
|
||||||
if verbose:
|
if verbose:
|
||||||
print(' cp ' + dpath + ' ' + tdpath)
|
print(' cpx ' + dpath + ' ' + tdpath)
|
||||||
shutil.copy(dpath, tdpath)
|
with open(dpath, 'rt') as infile:
|
||||||
|
with open(tdpath, 'wt') as outfile:
|
||||||
|
outfile.write(cleanup_dump(infile.read()))
|
||||||
if copy_cp:
|
if copy_cp:
|
||||||
if os.path.isfile(cpath):
|
if os.path.isfile(cpath):
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|
Loading…
Reference in a new issue