Commit 9efcb55b authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

regexpfiles usage with : and without :

parent 559533c6
......@@ -77,7 +77,13 @@ def inputfile(file):
return urlfile(file)
def regexpfiles(files_pattern):
folder, pattern = files_pattern.rsplit(':')
try:
if ':' in files_pattern:
folder, pattern = files_pattern.rsplit(':')
else:
folder, pattern = os.path.split(files_pattern)
except:
raise argparse.ArgumentTypeError("Pattern '" + file + "' is invalid!")
if not os.path.exists(folder):
raise argparse.ArgumentTypeError("The folder '" + folder + "' doesn't exist!")
if not os.access(folder, os.R_OK):
......@@ -856,7 +862,10 @@ class InputFileList(ParameterList, AbstractInputFile):
new_vals = list()
if self.type.__name__ == "regexpfiles":
for files_pattern in path2test:
folder, pattern = files_pattern.rsplit(':')
if ':' in files_pattern:
folder, pattern = files_pattern.rsplit(':')
else:
folder, pattern = os.path.split(files_pattern)
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)) )
......
......@@ -581,7 +581,7 @@ jQuery.validator.addMethod("mparam", function(value, element, params) {
' </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">',
' <input id="${param.name}" name="${param.name}" class="form-control ${param.group}" type="text" value="${param.default}">',
// 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