def get_parameter_value_from_file_names(files, parameters=None, unique=False, sort=True):
<EOL><INDENT>logging.debug('<STR_LIT>' + str(parameters) + '<STR_LIT>' + str(len(files)) + '<STR_LIT>')<EOL>files_dict = collections.OrderedDict()<EOL>if parameters is None:  <EOL><INDENT>return files_dict<EOL><DEDENT>if isinstance(parameters, str):<EOL><INDENT>parameters = (parameters, )<EOL><DEDENT>search_string = '<STR_LIT:_>'.join(parameters)<EOL>for _ in parameters:<EOL><INDENT>search_string += r'<STR_LIT>'<EOL><DEDENT>result = {}<EOL>for one_file in files:<EOL><INDENT>parameter_values = re.findall(search_string, one_file)<EOL>if parameter_values:<EOL><INDENT>if isinstance(parameter_values[<NUM_LIT:0>], tuple):<EOL><INDENT>parameter_values = list(reduce(lambda t1, t2: t1 + t2, parameter_values))<EOL><DEDENT>parameter_values = [[int(i), ] for i in parameter_values]  <EOL>files_dict[one_file] = dict(list(zip(parameters, parameter_values)))<EOL>if unique:  <EOL><INDENT>for key, value in list(files_dict.items()):<EOL><INDENT>if value not in list(result.values()):<EOL><INDENT>result[key] = value<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>result[one_file] = files_dict[one_file]<EOL><DEDENT><DEDENT><DEDENT>return collections.OrderedDict(sorted(iter(result.items()), key=itemgetter(<NUM_LIT:1>)) if sort else files_dict)<EOL><DEDENT>
Takes a list of files, searches for the parameter name in the file name and returns a ordered dict with the file name
in the first dimension and the corresponding parameter value in the second.
The file names can be sorted by the parameter value, otherwise the order is kept. If unique is true every parameter is unique and
mapped to the file name that occurred last in the files list.

Parameters
----------
files : list of strings
parameter : string or list of strings
unique : bool
sort : bool

Returns
-------
collections.OrderedDict