Skip to content

Commit c595f21

Browse files
Gareth Aneurin TribelloGareth Aneurin Tribello
authored andcommitted
Added option to allow you to set whether to look for json or not
1 parent 85d02e7 commit c595f21

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

PlumedToHTML/PlumedToHTML.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_and_get_html( inpt, name, actions=set({}) ) :
5555
# Now do the test
5656
broken = test_plumed( "plumed", filename, header="", shortcutfile=name + '.json', valuefile='values_' + name + '.json' )
5757
# Retrieve the html that is output by plumed
58-
html = get_html( inpt, name, name, ("master",), (broken,), ("plumed",), actions )
58+
html = get_html( inpt, name, name, ("master",), (broken,), ("plumed",), actions=actions )
5959
# Remove the tempory files that we created
6060
if not keepfile : os.remove(filename)
6161

@@ -155,7 +155,7 @@ def manage_incomplete_inputs( inpt ) :
155155
return complete, incomplete
156156
return inpt, ""
157157

158-
def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
158+
def get_html( inpt, name, outloc, tested, broken, plumedexe, usejson=None, actions=set({}) ) :
159159
"""
160160
Generate the html representation of a PLUMED input file
161161
@@ -171,9 +171,16 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
171171
tested -- The versions of plumed that were testd
172172
broken -- The outcome of running test plumed on the input
173173
plumedexe -- The plumed executibles that were used. The first one is the one that should be used to create the input file annotations
174+
usejson -- Bool that tells you whether or not to look for json files that are generated by plumed driver
174175
actions -- Set to store all the actions that have been used in the input
175176
"""
176177

178+
# Check if we are looking for json files
179+
if usejson is None :
180+
searchjson = False
181+
if not any(broken) : searchjson = True
182+
else : searchjson = usejson
183+
177184
# If we find the fill command then split up the input file to find the solution
178185
inpt, incomplete = manage_incomplete_inputs( inpt )
179186

@@ -185,7 +192,7 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
185192
found_load = "LOAD " in inpt
186193

187194
# Check for shortcut file and build the modified input to read the shortcuts
188-
if os.path.exists( name + '.json' ) and not any(broken) :
195+
if os.path.exists( name + '.json' ) and searchjson :
189196
# Read json file containing shortcuts
190197
with open(name + '.json') as f :
191198
try:
@@ -199,7 +206,7 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
199206
if os.path.exists( name + '.json' ) : os.remove( name + ".json")
200207

201208
# Check for value dictionary to use to create labels
202-
if os.path.exists( 'values_' + name + '.json') and not any(broken) :
209+
if os.path.exists( 'values_' + name + '.json') and searchjson :
203210
with open('values_' + name + '.json') as f :
204211
try:
205212
valuedict = json.load(f)
@@ -251,7 +258,7 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, actions=set({}) ) :
251258
try :
252259
etree.parse(StringIO(html), etree.HTMLParser(recover=False))
253260
except etree.XMLSyntaxError as e:
254-
raise Exception("Generated html is invalid as " + str(e.error_log) ) from e
261+
raise Exception("Generated html is invalid as " + str(e.error_log) + " plumed input is \n\n" + final_inpt ) from e
255262

256263
# Check everything that is marked as a clickable value has something that will appear
257264
# when you click it

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name='PlumedToHTML',
9-
version='0.61',
9+
version='0.62',
1010
author="Gareth Tribello",
1111
author_email="[email protected]",
1212
description="A package for creating pretified HTML for PLUMED files",

0 commit comments

Comments
 (0)