|
16 | 16 | from .utils import visit_class
|
17 | 17 |
|
18 | 18 |
|
19 |
| -def find_id(doc, frg): # type: (Any, Any) -> Optional[MutableMapping] |
20 |
| - if isinstance(doc, MutableMapping): |
21 |
| - if "id" in doc and doc["id"] == frg: |
22 |
| - return doc |
23 |
| - for key in doc: |
24 |
| - found = find_id(doc[key], frg) |
25 |
| - if found: |
26 |
| - return found |
27 |
| - if isinstance(doc, MutableSequence): |
28 |
| - for entry in doc: |
29 |
| - found = find_id(entry, frg) |
30 |
| - if found: |
31 |
| - return found |
32 |
| - return None |
33 |
| - |
34 |
| - |
35 |
| -def fixType(doc): # type: (Any) -> Any |
36 |
| - if isinstance(doc, MutableSequence): |
37 |
| - for i, f in enumerate(doc): |
38 |
| - doc[i] = fixType(f) |
39 |
| - return doc |
40 |
| - |
41 |
| - if isinstance(doc, string_types): |
42 |
| - if doc not in ( |
43 |
| - "null", "boolean", "int", "long", "float", "double", "string", |
44 |
| - "File", "record", "enum", "array", "Any") and "#" not in doc: |
45 |
| - return "#" + doc |
46 |
| - return doc |
47 |
| - |
48 |
| -digits = re.compile(r"\d+") |
49 |
| - |
50 |
| - |
51 |
| -def updateScript(sc): # type: (Text) -> Text |
52 |
| - sc = sc.replace("$job", "inputs") |
53 |
| - sc = sc.replace("$tmpdir", "runtime.tmpdir") |
54 |
| - sc = sc.replace("$outdir", "runtime.outdir") |
55 |
| - sc = sc.replace("$self", "self") |
56 |
| - return sc |
57 |
| - |
58 |
| - |
59 |
| -def _updateDev2Script(ent): # type: (Any) -> Any |
60 |
| - if isinstance(ent, MutableMapping) and "engine" in ent: |
61 |
| - if ent["engine"] == "https://w3id.org/cwl/cwl#JsonPointer": |
62 |
| - sp = ent["script"].split("/") |
63 |
| - if sp[0] in ("tmpdir", "outdir"): |
64 |
| - return u"$(runtime.%s)" % sp[0] |
65 |
| - if not sp[0]: |
66 |
| - sp.pop(0) |
67 |
| - front = sp.pop(0) |
68 |
| - sp = [Text(i) if digits.match(i) else "'" + i + "'" |
69 |
| - for i in sp] |
70 |
| - if front == "job": |
71 |
| - return u"$(inputs[%s])" % ']['.join(sp) |
72 |
| - if front == "context": |
73 |
| - return u"$(self[%s])" % ']['.join(sp) |
74 |
| - else: |
75 |
| - sc = updateScript(ent["script"]) |
76 |
| - if sc[0] == "{": |
77 |
| - return "$" + sc |
78 |
| - return u"$(%s)" % sc |
79 |
| - return ent |
80 |
| - |
81 |
| -def traverseImport(doc, loader, baseuri, func): |
82 |
| - # type: (Any, Loader, Text, Callable[[Any, Loader, Text], Any]) -> Any |
83 |
| - if "$import" in doc: |
84 |
| - if doc["$import"][0] == "#": |
85 |
| - return doc["$import"] |
86 |
| - imp = urllib.parse.urljoin(baseuri, doc["$import"]) |
87 |
| - impLoaded = loader.fetch(imp) |
88 |
| - r = {} # type: MutableMapping[Text, Any] |
89 |
| - if isinstance(impLoaded, MutableSequence): |
90 |
| - r = {"$graph": impLoaded} |
91 |
| - elif isinstance(impLoaded, MutableMapping): |
92 |
| - r = impLoaded |
93 |
| - else: |
94 |
| - raise Exception("Unexpected code path.") |
95 |
| - r["id"] = imp |
96 |
| - _, frag = urllib.parse.urldefrag(imp) |
97 |
| - if frag: |
98 |
| - frag = "#" + frag |
99 |
| - r = find_id(r, frag) # type: ignore |
100 |
| - return func(r, loader, imp) |
101 |
| - |
102 |
| -def v1_0dev4to1_0(doc, loader, baseuri): # pylint: disable=unused-argument |
103 |
| - # type: (Any, Loader, Text) -> Tuple[Any, Text] |
104 |
| - """Public updater for v1.0.dev4 to v1.0.""" |
105 |
| - return (doc, "v1.0") |
106 |
| - |
107 |
| - |
108 | 19 | def v1_0to1_1_0dev1(doc, loader, baseuri): # pylint: disable=unused-argument
|
109 | 20 | # type: (Any, Loader, Text) -> Tuple[Any, Text]
|
110 | 21 | """Public updater for v1.0 to v1.1.0-dev1."""
|
@@ -134,6 +45,7 @@ def add_networkaccess(t):
|
134 | 45 | ALLUPDATES.update(DEVUPDATES)
|
135 | 46 |
|
136 | 47 | LATEST = u"v1.0"
|
| 48 | +#LATEST = u"v1.1.0-dev1" |
137 | 49 |
|
138 | 50 |
|
139 | 51 | def identity(doc, loader, baseuri): # pylint: disable=unused-argument
|
|
0 commit comments