11# SPDX-License-Identifier: Apache-2.0
22# From https://github.com/rabix/sbpack/blob/b8404a0859ffcbe1edae6d8f934e51847b003320/sbpack/lib.py
33"""Shared Python type definitions for commons JSON like CWL objects."""
4+ import sys
45from collections .abc import MutableMapping , MutableSequence
5- from typing import TypeAlias , TypedDict
6+ from typing import Literal , TypeAlias , TypedDict
7+
8+ if sys .version_info >= (3 , 11 ):
9+ from typing import Required
10+ else :
11+ from typing_extensions import Required
12+
613
714built_in_types : list [str ] = [
815 "null" ,
2128]
2229
2330
31+ DirectoryDict = TypedDict (
32+ "DirectoryDict" ,
33+ {
34+ "class" : Required [Literal ["Directory" ]],
35+ "location" : str ,
36+ "path" : str ,
37+ "basename" : str ,
38+ "listing" : MutableSequence ["FileDict | DirectoryDict" ],
39+ },
40+ total = False ,
41+ )
42+
43+
44+ FileDict = TypedDict (
45+ "FileDict" ,
46+ {
47+ "class" : Required [Literal ["File" ]],
48+ "location" : str ,
49+ "path" : str ,
50+ "basename" : str ,
51+ "dirname" : str ,
52+ "nameroot" : str ,
53+ "nameext" : str ,
54+ "checksum" : str ,
55+ "size" : int ,
56+ "secondaryFiles" : MutableSequence ["FileDict | DirectoryDict" ],
57+ "format" : str ,
58+ "contents" : str ,
59+ },
60+ total = False ,
61+ )
62+
63+
2464CWLOutputAtomType : TypeAlias = (
2565 None
2666 | bool
2767 | str
2868 | int
29- | float
69+ | FileDict
70+ | DirectoryDict
3071 | MutableSequence ["CWLOutputAtomType" ]
3172 | MutableMapping [str , "CWLOutputAtomType" ]
3273)
3576 | str
3677 | int
3778 | float
79+ | FileDict
80+ | DirectoryDict
3881 | MutableSequence [CWLOutputAtomType ]
3982 | MutableMapping [str , CWLOutputAtomType ]
4083)
@@ -49,9 +92,16 @@ class CWLRuntimeParameterContext(TypedDict, total=False):
4992 ram : float | str
5093 outdirSize : float | str
5194 tmpdirSize : float | str
95+ exitCode : int
5296
5397
5498class CWLParameterContext (TypedDict , total = False ):
5599 inputs : CWLObjectType
56100 self : CWLOutputType | None
57101 runtime : CWLRuntimeParameterContext
102+
103+
104+ class DirentDict (TypedDict , total = False ):
105+ entry : Required [str ]
106+ entryname : str
107+ writable : bool
0 commit comments