@@ -97,8 +97,8 @@ def __init__(self):
97
97
self .hints = [] # List[Dict[Text, Any]]
98
98
99
99
def get_requirement (self ,
100
- feature # type: Text
101
- ): # type: (...) -> Tuple[Optional[Any], Optional[bool]]
100
+ feature # type: Text
101
+ ): # type: (...) -> Tuple[Optional[Any], Optional[bool]]
102
102
for item in reversed (self .requirements ):
103
103
if item ["class" ] == feature :
104
104
return (item , True )
@@ -109,93 +109,68 @@ def get_requirement(self,
109
109
110
110
class Builder (HasReqsHints ):
111
111
def __init__ (self ,
112
- job , # type: Dict[Text, Union[Dict[Text, Any], List, Text, None]]
113
- files = None , # type: List[Dict[Text, Text]]
114
- bindings = None , # type: List[Dict[Text, Any]]
115
- schemaDefs = None , # type: Dict[Text, Dict[Text, Any]]
116
- names = None , # type: Names
117
- requirements = None , # type: List[Dict[Text, Any]]
118
- hints = None , # type: List[Dict[Text, Any]]
119
- timeout = None , # type: float
120
- debug = False , # type: bool
121
- resources = None , # type: Dict[str, int ]
122
- js_console = False , # type: bool
123
- mutation_manager = None , # type: Optional[MutationManager]
124
- formatgraph = None , # type: Optional[Graph ]
125
- make_fs_access = None , # type: Type[StdFsAccess]
126
- fs_access = None , # type: StdFsAccess
127
- force_docker_pull = False , # type: bool
128
- loadListing = u"" , # type: Text
129
- outdir = u"" , # type: Text
130
- tmpdir = u"" , # type: Text
131
- stagedir = u"" , # type: Text
132
- job_script_provider = None # type: Optional[Any]
112
+ job , # type: Dict[Text, Union[Dict[Text, Any], List, Text, None]]
113
+ files , # type: List[Dict[Text, Text]]
114
+ bindings , # type: List[Dict[Text, Any]]
115
+ schemaDefs , # type: Dict[Text, Dict[Text, Any]]
116
+ names , # type: Names
117
+ requirements , # type: List[Dict[Text, Any]]
118
+ hints , # type: List[Dict[Text, Any]]
119
+ resources , # type: Dict[str, int]
120
+ mutation_manager , # type: Optional[MutationManager]
121
+ formatgraph , # type: Optional[Graph ]
122
+ make_fs_access , # type: Type[StdFsAccess]
123
+ fs_access , # type: StdFsAccess
124
+ job_script_provider , # type: Optional[Any ]
125
+ timeout , # type: float
126
+ debug , # type: bool
127
+ js_console , # type: bool
128
+ force_docker_pull , # type: bool
129
+ loadListing , # type: Text
130
+ outdir , # type: Text
131
+ tmpdir , # type: Text
132
+ stagedir , # type: Text
133
133
): # type: (...) -> None
134
134
135
- if names is None :
136
- self .names = Names ()
137
- else :
138
- self .names = names
139
-
140
- if schemaDefs is None :
141
- self .schemaDefs = {} # type: Dict[Text, Dict[Text, Any]]
142
- else :
143
- self .schemaDefs = schemaDefs
144
-
145
- if files is None :
146
- self .files = [] # type: List[Dict[Text, Text]]
147
- else :
148
- self .files = files
149
-
150
135
self .job = job
136
+ self .files = files
137
+ self .bindings = bindings
138
+ self .schemaDefs = schemaDefs
139
+ self .names = names
151
140
self .requirements = requirements
152
141
self .hints = hints
153
- self .outdir = outdir
154
- self .tmpdir = tmpdir
155
-
156
- if resources is None :
157
- self .resources = {} # type: Dict[str, int]
158
- else :
159
- self .resources = resources
142
+ self .resources = resources
143
+ self .mutation_manager = mutation_manager
144
+ self .formatgraph = formatgraph
160
145
161
- if bindings is None :
162
- self .bindings = [] # type: List[Dict[Text, Any]]
163
- else :
164
- self .bindings = bindings
165
- self .timeout = timeout
166
- self .pathmapper = None # type: Optional[PathMapper]
167
- self .stagedir = stagedir
146
+ self .make_fs_access = make_fs_access
147
+ self .fs_access = fs_access
168
148
169
- if make_fs_access is None :
170
- self .make_fs_access = StdFsAccess
171
- else :
172
- self .make_fs_access = make_fs_access
149
+ self .job_script_provider = job_script_provider
173
150
174
- if fs_access is None :
175
- self .fs_access = self .make_fs_access ("" )
176
- else :
177
- self .fs_access = fs_access
151
+ self .timeout = timeout
178
152
179
153
self .debug = debug
180
154
self .js_console = js_console
181
- self .mutation_manager = mutation_manager
182
155
self .force_docker_pull = force_docker_pull
183
- self .formatgraph = formatgraph
184
156
185
157
# One of "no_listing", "shallow_listing", "deep_listing"
186
158
self .loadListing = loadListing
187
- self .prov_obj = None # type: Optional[CreateProvProfile]
188
159
160
+ self .outdir = outdir
161
+ self .tmpdir = tmpdir
162
+ self .stagedir = stagedir
163
+
164
+ self .pathmapper = None # type: Optional[PathMapper]
165
+ self .prov_obj = None # type: Optional[CreateProvProfile]
189
166
self .find_default_container = None # type: Optional[Callable[[], Text]]
190
- self .job_script_provider = job_script_provider
191
167
192
168
def build_job_script (self , commands ):
193
169
# type: (List[Text]) -> Text
194
170
build_job_script_method = getattr (self .job_script_provider , "build_job_script" , None ) # type: Callable[[Builder, Union[List[str],List[Text]]], Text]
195
- if build_job_script_method :
171
+ if build_job_script_method is not None :
196
172
return build_job_script_method (self , commands )
197
- else :
198
- return None
173
+ return None
199
174
200
175
def bind_input (self ,
201
176
schema , # type: MutableMapping[Text, Any]
@@ -209,6 +184,7 @@ def bind_input(self,
209
184
tail_pos = []
210
185
if lead_pos is None :
211
186
lead_pos = []
187
+
212
188
bindings = [] # type: List[MutableMapping[Text, Text]]
213
189
binding = None # type: Optional[MutableMapping[Text,Any]]
214
190
value_from_expression = False
@@ -247,7 +223,11 @@ def bind_input(self,
247
223
raise validate .ValidationException (u"'%s' is not a valid union %s" % (datum , schema ["type" ]))
248
224
elif isinstance (schema ["type" ], MutableMapping ):
249
225
st = copy .deepcopy (schema ["type" ])
250
- if binding and "inputBinding" not in st and st ["type" ] == "array" and "itemSeparator" not in binding :
226
+ if binding is not None \
227
+ and "inputBinding" not in st \
228
+ and "type" in st \
229
+ and st ["type" ] == "array" \
230
+ and "itemSeparator" not in binding :
251
231
st ["inputBinding" ] = {}
252
232
for k in ("secondaryFiles" , "format" , "streamable" ):
253
233
if k in schema :
@@ -270,7 +250,7 @@ def bind_input(self,
270
250
if schema ["type" ] == "array" :
271
251
for n , item in enumerate (datum ):
272
252
b2 = None
273
- if binding :
253
+ if binding is not None :
274
254
b2 = copy .deepcopy (binding )
275
255
b2 ["datum" ] = item
276
256
itemschema = {
@@ -341,7 +321,7 @@ def _capture_files(f):
341
321
self .files .append (datum )
342
322
343
323
# Position to front of the sort key
344
- if binding :
324
+ if binding is not None :
345
325
for bi in bindings :
346
326
bi ["position" ] = binding ["position" ] + bi ["position" ]
347
327
bindings .append (binding )
0 commit comments