Skip to content

Commit 85d02e7

Browse files
Gareth Aneurin TribelloGareth Aneurin Tribello
authored andcommitted
Small fix to ensure that broken json files created by plumed are deleted as well as the OK ones
1 parent 417353c commit 85d02e7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

PlumedToHTML/PlumedToHTML.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
194194
raise Exception("invalid json for shortcut dictionary", ve)
195195
# Put everything in to resolve the expansions. We call this function recursively just in case there are shortcuts in shortcuts
196196
final_inpt = resolve_expansions( inpt, shortcutdata )
197-
# Remove the tempory files that we created
198-
os.remove( name + ".json")
199-
else : final_inpt = inpt
197+
else : final_inpt = inpt
198+
# Remove the tempory files that we created
199+
if os.path.exists( name + '.json' ) : os.remove( name + ".json")
200200

201201
# Check for value dictionary to use to create labels
202202
if os.path.exists( 'values_' + name + '.json') and not any(broken) :
@@ -205,9 +205,9 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
205205
valuedict = json.load(f)
206206
except json.JSONDecodeError as ve:
207207
raise Exception("invalid json for value dictionary", ve)
208-
# Remove the tempory files that we created
209-
os.remove( 'values_' + name + ".json")
210208
else : valuedict = {}
209+
# Remove the tempory files that we created
210+
if os.path.exists( 'values_' + name + '.json') : os.remove( 'values_' + name + ".json")
211211

212212
# Create the lexer that will generate the pretty plumed input
213213
lexerfile = os.path.join(os.path.dirname(__file__),"PlumedLexer.py")

0 commit comments

Comments
 (0)