Commit 559533c6 authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

Add regexpfile in GUI.

parent d093739b
......@@ -76,13 +76,13 @@ def inputfile(file):
else:
return urlfile(file)
def regexpfile(file_pattern):
folder, pattern = file_pattern.rsplit(':')
files = list()
for item in os.listdir(folder):
if os.path.isfile(os.path.join(folder, item)) and fnmatch.fnmatch(item, pattern):
files.append( localfile(os.path.join(folder, item)) )
return files
def regexpfiles(files_pattern):
folder, pattern = files_pattern.rsplit(':')
if not os.path.exists(folder):
raise argparse.ArgumentTypeError("The folder '" + folder + "' doesn't exist!")
if not os.access(folder, os.R_OK):
raise argparse.ArgumentTypeError("You do not have permission to read '" + folder + "'!")
return files_pattern
def create_test_function(itype):
try: itype = itype.encode('ascii','ignore')
......@@ -819,7 +819,7 @@ class InputFileList(ParameterList, AbstractInputFile):
type2test = type.__name__
else: type2test = type
if type2test not in INPUTFILE_TYPES + ["regexpfile"]:
if type2test not in INPUTFILE_TYPES + ["regexpfiles"]:
raise ValueError("InputFile.__new__: wrong type provided: '"+type2test+"', this should be choosen between '"
+ "', '".join(INPUTFILE_TYPES)+"'")
......@@ -852,6 +852,15 @@ class InputFileList(ParameterList, AbstractInputFile):
path2test = _copy.deepcopy(inputs)
if not path2test.__class__.__name__ == "list":
path2test = [path2test]
# handle regexp files
new_vals = list()
if self.type.__name__ == "regexpfiles":
for files_pattern in path2test:
folder, pattern = files_pattern.rsplit(':')
for item in os.listdir(folder):
if os.path.isfile(os.path.join(folder, item)) and fnmatch.fnmatch(item, pattern):
new_vals.append( localfile(os.path.join(folder, item)) )
path2test = new_vals
new_vals, done = [], []
# handle url inputs
for path in path2test:
......
......@@ -245,12 +245,6 @@ class Workflow(threading.Thread):
group=parameter.group, display_name=parameter.display_name )
elif parameter.__class__ == InputFileList:
if value == "" : value = [] # from GUI
if parameter.type.__name__ == "regexpfile":
new_value = list()
for fileslist in value:
for file in fileslist:
new_value.append(file)
value = new_value
new_param = InputFileList( parameter.name, parameter.help, file_format=parameter.file_format, default=parameter.prepare_input_files(value),
type=parameter.type, choices=parameter.choices, required=parameter.required, flag=parameter.flag,
group=parameter.group, display_name=parameter.display_name, size_limit=parameter.size_limit )
......
......@@ -579,6 +579,9 @@ jQuery.validator.addMethod("mparam", function(value, element, params) {
' <button id="urlfile_btn_${param.name}" class="btn btn-default" type="button"><span class="glyphicon glyphicon-folder-open"></span></button>',
' </span>',
' </div>',
// if param is a regexpfiles
'{{else param.type.indexOf("regexpfiles") === 0}}',
' <input id="${param.name}" name="${param.name}" class="form-control ${param.group}" type="text" value="${param.default}" placeholder="Folder:Pattern">',
// if param is a boolean
'{{else param.type == "bool"}}',
// ' <div class="checkbox-inline">',
......
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