Commit 5fcfd559 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

correct a bug in mids description

parent bae432bf
......@@ -398,22 +398,46 @@ class Analyse (object):
run_id = self.__get_run_id()
my_run = Run.get_from_id(run_id)
mids_desc = my_run.get_mids_description()
# In case of multiple description take the longuest
# Look at all description available
best_description = {}
for mid_desc in mids_desc.keys():
mid_desc_regex = re.compile(".*" + mid_desc + ".*")
mdr = mid_desc_regex.match(file)
if mdr != None:
best_description[mid_desc] = mids_desc[mid_desc]
final_description = os.path.splitext(file)[0]
# If more than a description match, take the longuest
max_len = 0
final_descriptions = {}
final_description = os.path.splitext(file)[0]
if len(best_description) > 0:
for bdescription in best_description.keys():
# If this is the longuest seen so far
if len(bdescription) > max_len:
max_len = len(bdescription)
final_descriptions = {}
final_descriptions[bdescription] = best_description[bdescription]
final_description = best_description[bdescription]
# If an other one is as long
elif len(bdescription) == max_len:
final_descriptions[bdescription] = best_description[bdescription]
# If we have more than 1 description available, use the one in between .[desc].
if len(final_descriptions) > 1:
for final_desc in final_descriptions.keys():
mid_desc_regex = re.compile(".*\." + final_desc + "\..*")
mdr = mid_desc_regex.match(file)
if mdr != None:
final_description = final_descriptions[final_desc]
# Return the description
return final_description
except :
# Return the file name
return os.path.splitext(file)[0]
......
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