Skip to content

Commit ebe65dc

Browse files
committed
add flag to allow for spaces in file names
1 parent feb1326 commit ebe65dc

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

cwltool/draft2tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
from .job import CommandLineJob
2626
from .stdfsaccess import StdFsAccess
2727

28-
ACCEPTLIST_RE = re.compile(r"^[a-zA-Z0-9._+-]+$")
28+
ACCEPTLIST_EN_STRICT_RE = re.compile(r"^[a-zA-Z0-9._+-]+$")
29+
ACCEPTLIST_EN_RELAXED_RE = re.compile(r"^[ a-zA-Z0-9._+-]+$") # with spaces
30+
ACCEPTLIST_RE = ACCEPTLIST_EN_STRICT_RE
2931

3032
from .flatten import flatten
3133

cwltool/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
178178
help="Do not compute checksum of contents while collecting outputs",
179179
dest="compute_checksum")
180180

181+
parser.add_argument("--relax-path-checks", action="store_true",
182+
default=False, help="Relax requirements on path names. Currently "
183+
"allows spaces.", dest="relax_path_checks")
181184
parser.add_argument("workflow", type=Text, nargs="?", default=None)
182185
parser.add_argument("job_order", nargs=argparse.REMAINDER)
183186

@@ -616,6 +619,8 @@ def main(argsl=None,
616619
_logger.error("")
617620
_logger.error("CWL document required, try --help for details")
618621
return 1
622+
if args.relax_path_checks:
623+
draft2tool.ACCEPTLIST_RE = draft2tool.ACCEPTLIST_EN_RELAXED_RE
619624

620625
try:
621626
document_loader, workflowobj, uri = fetch_document(args.workflow, resolver=tool_resolver)

tests/test_relax_path_checks.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import unittest
2+
from tempfile import NamedTemporaryFile
3+
from cwltool.main import main
4+
5+
6+
class ToolArgparse(unittest.TestCase):
7+
8+
9+
script='''
10+
#!/usr/bin/env cwl-runner
11+
cwlVersion: v1.0
12+
class: CommandLineTool
13+
inputs:
14+
- id: input
15+
type: File
16+
inputBinding:
17+
position: 0
18+
outputs:
19+
- id: output
20+
type: File
21+
outputBinding:
22+
glob: test.txt
23+
stdout: test.txt
24+
baseCommand: [cat]
25+
'''
26+
27+
def test_spaces_in_input_files(self):
28+
with NamedTemporaryFile() as f:
29+
f.write(self.script)
30+
f.flush()
31+
with NamedTemporaryFile(prefix="test with spaces") as spaces:
32+
self.assertEquals(
33+
main(["--debug", f.name, '--input', spaces.name]), 1)
34+
self.assertEquals(
35+
main(["--debug", "--relax-path-checks", f.name, '--input',
36+
spaces.name]), 0)
37+
38+
if __name__ == '__main__':
39+
unittest.main()

0 commit comments

Comments
 (0)