15358: Add encoding option to CollectionFsAccess.open() and use in fetch_text()
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 3 Jul 2019 18:03:33 +0000 (14:03 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Wed, 3 Jul 2019 18:06:01 +0000 (14:06 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

sdk/cwl/arvados_cwl/fsaccess.py

index 252ca57d47bb30ad1834e7070b3cfdf1e0ffdbb1..c1ea586b0475db4c5b1a780fea5eab11bb02d11f 100644 (file)
@@ -133,10 +133,10 @@ class CollectionFsAccess(cwltool.stdfsaccess.StdFsAccess):
         patternsegments = rest.split("/")
         return sorted(self._match(collection, patternsegments, "keep:" + collection.manifest_locator()))
 
-    def open(self, fn, mode):
+    def open(self, fn, mode, encoding=None):
         collection, rest = self.get_collection(fn)
         if collection is not None:
-            return collection.open(rest, mode)
+            return collection.open(rest, mode, encoding=encoding)
         else:
             return super(CollectionFsAccess, self).open(self._abs(fn), mode)
 
@@ -225,7 +225,7 @@ class CollectionFetcher(DefaultFetcher):
 
     def fetch_text(self, url):
         if url.startswith("keep:"):
-            with self.fsaccess.open(url, "r") as f:
+            with self.fsaccess.open(url, "r", encoding="utf-8") as f:
                 return f.read()
         if url.startswith("arvwf:"):
             record = self.api_client.workflows().get(uuid=url[6:]).execute(num_retries=self.num_retries)