Commit b81de0e5 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Add get_query_from_filename : standardized way to get the query from a filename

parent ae4c920c
......@@ -41,6 +41,29 @@ import cadbiom.commons as cm
LOGGER = cm.logger()
## Generic #####################################################################
def get_query_from_filename(model_file, solution_file):
"""Return the query string according to the given model and solution filenames
:param model_file: Path of a bcx model.
:param solution_file: Path of a solution file (\*cam\* file).
:type model_file: <str>
:type solution_file: <str>
"""
model_filename = os.path.basename(os.path.splitext(model_file)[0])
solution_filename = os.path.basename(os.path.splitext(solution_file)[0])
solution_filename = solution_filename.replace(model_filename, '')
if '_cam_complete' in solution_filename:
# remove _cam_complete
return solution_filename[:-13]
elif '_cam' in solution_filename:
# remove _cam
return solution_filename[:-4]
## Handle *cam_complete.txt files ##############################################
def load_solutions(file):
......@@ -251,7 +274,7 @@ def get_solutions(file_descriptor):
"""Generator of solution lines and corresponding stripped lines for
*cam* file.
.. note:: This function do not return events! It is just original lines and
.. note:: This function does not return events! It is just original lines and
cleaned lines containing solutions (i.e sets of frontier
places/boundaries).
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment