6
6
from typing import Any , Union , AnyStr , Callable
7
7
from .errors import WorkflowException
8
8
from .stdfsaccess import StdFsAccess
9
- from .pathmapper import PathMapper
9
+ from .pathmapper import PathMapper , adjustFileObjs , adjustDirObjs
10
10
11
11
CONTENT_LIMIT = 64 * 1024
12
12
@@ -17,18 +17,6 @@ def substitute(value, replace): # type: (str, str) -> str
17
17
else :
18
18
return value + replace
19
19
20
- def adjustFileObjs (rec , op ): # type: (Any, Callable[[Any], Any]) -> None
21
- """Apply an update function to each File object in the object `rec`."""
22
-
23
- if isinstance (rec , dict ):
24
- if rec .get ("class" ) == "File" :
25
- op (rec )
26
- for d in rec :
27
- adjustFileObjs (rec [d ], op )
28
- if isinstance (rec , list ):
29
- for d in rec :
30
- adjustFileObjs (d , op )
31
-
32
20
class Builder (object ):
33
21
34
22
def __init__ (self ): # type: () -> None
@@ -114,7 +102,7 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
114
102
if schema ["type" ] == "File" :
115
103
self .files .append (datum )
116
104
if binding and binding .get ("loadContents" ):
117
- with self .fs_access .open (datum ["path " ], "rb" ) as f :
105
+ with self .fs_access .open (datum ["location " ], "rb" ) as f :
118
106
datum ["contents" ] = f .read (CONTENT_LIMIT )
119
107
120
108
if "secondaryFiles" in schema :
@@ -124,11 +112,11 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
124
112
if isinstance (sf , dict ) or "$(" in sf or "${" in sf :
125
113
secondary_eval = self .do_eval (sf , context = datum )
126
114
if isinstance (secondary_eval , basestring ):
127
- sfpath = {"path " : secondary_eval , "class" : "File" }
115
+ sfpath = {"location " : secondary_eval , "class" : "File" }
128
116
else :
129
117
sfpath = secondary_eval
130
118
else :
131
- sfpath = {"path " : substitute (datum ["path " ], sf ), "class" : "File" }
119
+ sfpath = {"location " : substitute (datum ["location " ], sf ), "class" : "File" }
132
120
if isinstance (sfpath , list ):
133
121
datum ["secondaryFiles" ].extend (sfpath )
134
122
else :
@@ -140,6 +128,10 @@ def _capture_files(f):
140
128
141
129
adjustFileObjs (datum .get ("secondaryFiles" , []), _capture_files )
142
130
131
+ if schema ["type" ] == "Directory" :
132
+ self .files .append (datum )
133
+
134
+
143
135
# Position to front of the sort key
144
136
if binding :
145
137
for bi in bindings :
0 commit comments