1414import urllib .parse
1515from collections .abc import (
1616 Generator ,
17- Iterable ,
1817 Mapping ,
1918 MutableMapping ,
2019 MutableSequence ,
2120)
2221from enum import Enum
2322from functools import cmp_to_key , partial
2423from re import Pattern
25- from typing import TYPE_CHECKING , Any , Optional , TextIO , Union , cast
24+ from typing import Any , Optional , TYPE_CHECKING , TextIO , Union , cast
2625
2726from cwl_utils .types import (
2827 CWLDirectoryType ,
4241from schema_salad .utils import json_dumps
4342from schema_salad .validate import validate_ex
4443
45- from .builder import (
46- INPUT_OBJ_VOCAB ,
47- Builder ,
48- content_limit_respected_read_bytes ,
49- substitute ,
50- )
44+ from .builder import Builder , INPUT_OBJ_VOCAB , content_limit_respected_read_bytes , substitute
5145from .context import LoadingContext , RuntimeContext , getdefault
5246from .docker import DockerCommandLineJob , PodmanCommandLineJob
5347from .errors import UnsupportedRequirement , WorkflowException
@@ -1292,7 +1286,7 @@ def collect_output(
12921286 fs_access : StdFsAccess ,
12931287 compute_checksum : bool = True ,
12941288 ) -> CWLOutputType | None :
1295- r : list [ CWLOutputType ] = []
1289+ r : MutableSequence [ CWLFileType | CWLDirectoryType ] = []
12961290 empty_and_optional = False
12971291 debug = _logger .isEnabledFor (logging .DEBUG )
12981292 result : CWLOutputType | None = None
@@ -1340,9 +1334,9 @@ def collect_output(
13401334 key = cmp_to_key (locale .strcoll ),
13411335 )
13421336 r .extend (
1343- cast (
1344- Iterable [ CWLOutputType ],
1345- [
1337+ [
1338+ cast (
1339+ CWLFileType | CWLDirectoryType ,
13461340 {
13471341 "location" : g ,
13481342 "path" : fs_access .join (
@@ -1353,31 +1347,31 @@ def collect_output(
13531347 "nameroot" : os .path .splitext (decoded_basename )[0 ],
13541348 "nameext" : os .path .splitext (decoded_basename )[1 ],
13551349 "class" : "File" if fs_access .isfile (g ) else "Directory" ,
1356- }
1357- for g , decoded_basename in zip (
1350+ },
1351+ )
1352+ for g , decoded_basename in zip (
1353+ sorted_glob_result ,
1354+ map (
1355+ lambda x : os .path .basename (urllib .parse .unquote (x )),
13581356 sorted_glob_result ,
1359- map (
1360- lambda x : os .path .basename (urllib .parse .unquote (x )),
1361- sorted_glob_result ,
1362- ),
1363- )
1364- ],
1365- )
1357+ ),
1358+ )
1359+ ]
13661360 )
13671361 except OSError as e :
13681362 _logger .warning (str (e ), exc_info = builder .debug )
13691363 except Exception :
13701364 _logger .error ("Unexpected error from fs_access" , exc_info = True )
13711365 raise
13721366
1373- for files in cast ( MutableSequence [ CWLFileType | CWLDirectoryType ], r ) :
1367+ for files in r :
13741368 rfile = files .copy ()
13751369 revmap (rfile )
13761370 if is_directory (files ):
13771371 ll = binding .get ("loadListing" ) or builder .loadListing
13781372 if ll and ll != "no_listing" :
13791373 get_listing (fs_access , files , (ll == "deep_listing" ))
1380- elif is_file ( files ) :
1374+ else :
13811375 if binding .get ("loadContents" ):
13821376 with fs_access .open (rfile ["location" ], "rb" ) as f :
13831377 files ["contents" ] = str (
0 commit comments