33from . import expression
44import avro
55import schema_salad .validate as validate
6- from typing import Any , Union , AnyStr , Callable , Type
6+ from typing import Any , Callable , Text , Type , Union
77from .errors import WorkflowException
88from .stdfsaccess import StdFsAccess
99from .pathmapper import PathMapper , adjustFileObjs , adjustDirObjs , normalizeFilesDirs
1010
1111CONTENT_LIMIT = 64 * 1024
1212
1313
14- def substitute (value , replace ): # type: (str, str ) -> str
14+ def substitute (value , replace ): # type: (Text, Text ) -> Text
1515 if replace [0 ] == "^" :
1616 return substitute (value [0 :value .rindex ('.' )], replace [1 :])
1717 else :
@@ -21,24 +21,24 @@ class Builder(object):
2121
2222 def __init__ (self ): # type: () -> None
2323 self .names = None # type: avro.schema.Names
24- self .schemaDefs = None # type: Dict[str, Dict[unicode , Any]]
25- self .files = None # type: List[Dict[unicode, unicode ]]
24+ self .schemaDefs = None # type: Dict[Text, Dict[Text , Any]]
25+ self .files = None # type: List[Dict[Text, Text ]]
2626 self .fs_access = None # type: StdFsAccess
27- self .job = None # type: Dict[unicode , Union[Dict[unicode , Any], List, unicode ]]
28- self .requirements = None # type: List[Dict[str, Any]]
29- self .outdir = None # type: str
30- self .tmpdir = None # type: str
31- self .resources = None # type: Dict[str , Union[int, str ]]
32- self .bindings = [] # type: List[Dict[str , Any]]
27+ self .job = None # type: Dict[Text , Union[Dict[Text , Any], List, Text ]]
28+ self .requirements = None # type: List[Dict[Text, Any]]
29+ self .outdir = None # type: Text
30+ self .tmpdir = None # type: Text
31+ self .resources = None # type: Dict[Text , Union[int, Text ]]
32+ self .bindings = [] # type: List[Dict[Text , Any]]
3333 self .timeout = None # type: int
3434 self .pathmapper = None # type: PathMapper
35- self .stagedir = None # type: unicode
35+ self .stagedir = None # type: Text
3636 self .make_fs_access = None # type: Type[StdFsAccess]
3737
3838 def bind_input (self , schema , datum , lead_pos = [], tail_pos = []):
39- # type: (Dict[unicode , Any], Any, Union[int, List[int]], List[int]) -> List[Dict[str , Any]]
40- bindings = [] # type: List[Dict[str,str ]]
41- binding = None # type: Dict[str ,Any]
39+ # type: (Dict[Text , Any], Any, Union[int, List[int]], List[int]) -> List[Dict[Text , Any]]
40+ bindings = [] # type: List[Dict[Text,Text ]]
41+ binding = None # type: Dict[Text ,Any]
4242 if "inputBinding" in schema and isinstance (schema ["inputBinding" ], dict ):
4343 binding = copy .copy (schema ["inputBinding" ])
4444
@@ -52,7 +52,7 @@ def bind_input(self, schema, datum, lead_pos=[], tail_pos=[]):
5252 # Handle union types
5353 if isinstance (schema ["type" ], list ):
5454 for t in schema ["type" ]:
55- if isinstance (t , (str , unicode )) and self .names .has_name (t , "" ):
55+ if isinstance (t , (str , Text )) and self .names .has_name (t , "" ):
5656 avsc = self .names .get_name (t , "" )
5757 elif isinstance (t , dict ) and "name" in t and self .names .has_name (t ["name" ], "" ):
5858 avsc = self .names .get_name (t ["name" ], "" )
@@ -134,23 +134,23 @@ def _capture_files(f):
134134
135135 return bindings
136136
137- def tostr (self , value ): # type: (Any) -> str
137+ def tostr (self , value ): # type: (Any) -> Text
138138 if isinstance (value , dict ) and value .get ("class" ) in ("File" , "Directory" ):
139139 if "path" not in value :
140140 raise WorkflowException (u"%s object missing \" path\" : %s" % (value ["class" ], value ))
141141 return value ["path" ]
142142 else :
143- return str (value )
143+ return Text (value )
144144
145- def generate_arg (self , binding ): # type: (Dict[str ,Any]) -> List[str ]
145+ def generate_arg (self , binding ): # type: (Dict[Text ,Any]) -> List[Text ]
146146 value = binding .get ("datum" )
147147 if "valueFrom" in binding :
148148 value = self .do_eval (binding ["valueFrom" ], context = value )
149149
150150 prefix = binding .get ("prefix" )
151151 sep = binding .get ("separate" , True )
152152
153- l = [] # type: List[Dict[str,str ]]
153+ l = [] # type: List[Dict[Text,Text ]]
154154 if isinstance (value , list ):
155155 if binding .get ("itemSeparator" ):
156156 l = [binding ["itemSeparator" ].join ([self .tostr (v ) for v in value ])]
@@ -182,7 +182,7 @@ def generate_arg(self, binding): # type: (Dict[str,Any]) -> List[str]
182182 return [a for a in args if a is not None ]
183183
184184 def do_eval (self , ex , context = None , pull_image = True , recursive = False ):
185- # type: (Union[Dict[str, str ], unicode ], Any, bool, bool) -> Any
185+ # type: (Union[Dict[Text, Text ], Text ], Any, bool, bool) -> Any
186186 if recursive :
187187 if isinstance (ex , dict ):
188188 return {k : self .do_eval (v , context , pull_image , recursive ) for k ,v in ex .iteritems ()}
0 commit comments