Skip to content

Commit

Permalink
foliaupgrade dryrun behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Mar 25, 2019
1 parent d131bb4 commit b2d230c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions foliatools/foliaupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ def process(*files, **kwargs):
print("Upgrading " + doc.filename,file=sys.stderr)
doc.version = folia.FOLIAVERSION #upgrading involves more than just bumping the number, but that is handled implicitly already by the library when reading the document
annotators2processors(doc, mainprocessor)
if not kwargs.get('dryrun'):
doc.save(doc.filename + ".upgraded")
if not validate(file + ".upgraded",schema=None,stricttextvalidation=True,autodeclare=True,**kwargs):
print("Upgrade failed",file=sys.stderr)
success = False
doc.save(doc.filename + ".upgraded")
if not validate(file + ".upgraded",schema=None,stricttextvalidation=True,autodeclare=False,traceback=True,**kwargs):
print("Upgrade failed",file=sys.stderr)
success = False
else:
print("Upgrade OK",file=sys.stderr)
if kwargs.get('dryrun'):
os.unlink(doc.filename+".upgraded")
print(doc.xmlstring())
else:
shutil.move(doc.filename + ".upgraded", file)
else:
print(doc.xmlstring())
else:
success = False
return success
Expand Down

0 comments on commit b2d230c

Please sign in to comment.