Skip to content

Commit cae5349

Browse files
committed
release v0.12
1 parent 6f53789 commit cae5349

16 files changed

+220
-275
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ EXTRAS=
2626

2727
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2828
# `[[` conditional expressions.
29-
PYSOURCES=$(filter-out parser/cwl_v%,$(shell find $(MODULE) -name "*.py")) $(wildcard tests/*.py) *.py
29+
PYSOURCES=$(filter-out $(MODULE)/parser/cwl_v%,$(shell find $(MODULE) -name "*.py")) $(wildcard tests/*.py) $(wildcard *.py)
3030
DEVPKGS=diff_cover black pylint pep257 pydocstyle flake8 tox tox-pyenv \
3131
isort wheel autoflake flake8-bugbear pyupgrade bandit \
3232
-rtest-requirements.txt -rmypy-requirements.txt

create_cwl_from_objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env python3
22
# SPDX-License-Identifier: Apache-2.0
3-
from cwl_utils.parser import cwl_v1_2 as cwl
4-
53
from ruamel import yaml
64

5+
from cwl_utils.parser import cwl_v1_2 as cwl
6+
77

88
def main() -> None:
99
"""Generate a CWL object to match "cat-tool.cwl"."""

cwl_utils/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Global version number for the cwl_utils package."""
2-
__version__ = "0.11"
2+
__version__ = "0.12"

cwl_utils/cwl_expression_refactor.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
from pathlib import Path
1010
from typing import (
11+
TYPE_CHECKING,
1112
Any,
1213
Callable,
1314
Dict,
@@ -16,7 +17,6 @@
1617
Optional,
1718
Tuple,
1819
Union,
19-
TYPE_CHECKING,
2020
)
2121

2222
from cwltool.loghandler import _logger as _cwltoollogger
@@ -38,12 +38,7 @@
3838
cwl_v1_1_expression_refactor,
3939
cwl_v1_2_expression_refactor,
4040
)
41-
42-
from cwl_utils.parser import (
43-
cwl_v1_0,
44-
cwl_v1_1,
45-
cwl_v1_2,
46-
)
41+
from cwl_utils.parser import cwl_v1_0, cwl_v1_1, cwl_v1_2
4742

4843
save_type = Union[Dict[str, str], List[Union[Dict[str, str], List[Any], None]], None]
4944

@@ -109,7 +104,7 @@ def run(args: argparse.Namespace) -> int:
109104
"""Primary processing loop."""
110105
for document in args.inputs:
111106
_logger.info("Processing %s.", document)
112-
with open(document, "r") as doc_handle:
107+
with open(document) as doc_handle:
113108
result = yaml.main.round_trip_load(doc_handle, preserve_quotes=True)
114109
version = result["cwlVersion"]
115110
uri = Path(document).resolve().as_uri()

cwl_utils/cwl_normalizer.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
import sys
88
import tempfile
99
from pathlib import Path
10-
from typing import (
11-
List,
12-
MutableSequence,
13-
Optional,
14-
Set,
15-
)
10+
from typing import List, MutableSequence, Optional, Set
1611

1712
from cwltool.context import LoadingContext, RuntimeContext
1813
from cwltool.load_tool import (
@@ -89,7 +84,7 @@ def run(args: argparse.Namespace) -> int:
8984
imports: Set[str] = set()
9085
for document in args.inputs:
9186
_logger.info("Processing %s.", document)
92-
with open(document, "r") as doc_handle:
87+
with open(document) as doc_handle:
9388
result = yaml.main.round_trip_load(doc_handle, preserve_quotes=True)
9489
add_lc_filename(result, document)
9590
version = result.get("cwlVersion", None)

cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 55 additions & 73 deletions
Large diffs are not rendered by default.

cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 55 additions & 73 deletions
Large diffs are not rendered by default.

cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 57 additions & 77 deletions
Large diffs are not rendered by default.

cwl_utils/docker_extract.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ def get_process_from_step(step: cwl.WorkflowStep) -> ProcessType:
9898
def traverse_workflow(workflow: cwl.Workflow) -> Iterator[cwl.DockerRequirement]:
9999
"""Iterate over the steps of this workflow, yielding the docker reqs."""
100100
for step in workflow.steps:
101-
for req in extract_docker_reqs(step):
102-
yield req
101+
yield from extract_docker_reqs(step)
103102
yield from traverse(get_process_from_step(step))
104103

105104

cwl_utils/graph_split.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def main() -> None:
5858
"""Split the packed CWL at the path of the first argument."""
5959
options = arg_parser().parse_args()
6060

61-
with open(options.cwlfile, "r") as source_handle:
61+
with open(options.cwlfile) as source_handle:
6262
run(
6363
source_handle,
6464
options.outdir,
@@ -95,10 +95,10 @@ def my_represent_none(
9595
imports = rewrite(entry, entry_id)
9696
if imports:
9797
for import_name in imports:
98-
rewrite_types(entry, "#{}".format(import_name), False)
98+
rewrite_types(entry, f"#{import_name}", False)
9999
if entry_id == "main":
100100
if mainfile is None:
101-
entry_id = "unpacked_{}".format(os.path.basename(sourceIO.name))
101+
entry_id = f"unpacked_{os.path.basename(sourceIO.name)}"
102102
else:
103103
entry_id = mainfile
104104

@@ -112,7 +112,7 @@ def my_represent_none(
112112
def rewrite(document: Any, doc_id: str) -> Set[str]:
113113
"""Rewrite the given element from the CWL $graph."""
114114
imports = set()
115-
if isinstance(document, list) and not isinstance(document, Text):
115+
if isinstance(document, list) and not isinstance(document, str):
116116
for entry in document:
117117
imports.update(rewrite(entry, doc_id))
118118
elif isinstance(document, dict):
@@ -133,22 +133,20 @@ def rewrite_id(entry: Any) -> Union[MutableMapping[Any, Any], str]:
133133
elif isinstance(entry, str):
134134
if entry.startswith(this_id):
135135
return entry[len(this_id) + 1 :]
136-
raise Exception(
137-
"{} is neither a dictionary nor string.".format(entry)
138-
)
136+
raise Exception(f"{entry} is neither a dictionary nor string.")
139137

140138
document[key][:] = [rewrite_id(entry) for entry in value]
141139
elif key in ("source", "scatter", "items", "format"):
142140
if (
143-
isinstance(value, Text)
141+
isinstance(value, str)
144142
and value.startswith("#")
145143
and "/" in value
146144
):
147145
referrant_file, sub = value[1:].split("/", 1)
148146
if referrant_file == doc_id:
149147
document[key] = sub
150148
else:
151-
document[key] = "{}#{}".format(referrant_file, sub)
149+
document[key] = f"{referrant_file}#{sub}"
152150
elif isinstance(value, list):
153151
new_sources = list()
154152
for entry in value:
@@ -174,15 +172,15 @@ def rewrite_import(document: MutableMapping[str, Any]) -> None:
174172

175173
def rewrite_types(field: Any, entry_file: str, sameself: bool) -> None:
176174
"""Clean up the names of the types."""
177-
if isinstance(field, list) and not isinstance(field, Text):
175+
if isinstance(field, list) and not isinstance(field, str):
178176
for entry in field:
179177
rewrite_types(entry, entry_file, sameself)
180178
return
181179
if isinstance(field, dict):
182180
for key, value in field.items():
183181
for name in ("type", "items"):
184182
if key == name:
185-
if isinstance(value, Text) and value.startswith(entry_file):
183+
if isinstance(value, str) and value.startswith(entry_file):
186184
if sameself:
187185
field[key] = value[len(entry_file) + 1 :]
188186
else:
@@ -191,7 +189,7 @@ def rewrite_types(field: Any, entry_file: str, sameself: bool) -> None:
191189
)
192190
if isinstance(value, dict):
193191
rewrite_types(value, entry_file, sameself)
194-
if isinstance(value, list) and not isinstance(value, Text):
192+
if isinstance(value, list) and not isinstance(value, str):
195193
for entry in value:
196194
rewrite_types(entry, entry_file, sameself)
197195

0 commit comments

Comments
 (0)