File: create_cwl_from_objects.py

package info (click to toggle)
cwl-utils 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 5,156 kB
  • sloc: python: 88,920; makefile: 141; javascript: 91
file content (33 lines) | stat: -rwxr-xr-x 790 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
import sys

import ruamel.yaml

from cwl_utils.parser import cwl_v1_2 as cwl


def main() -> None:
    """Generate a CWL object to match "cat-tool.cwl"."""
    inputs = [cwl.CommandInputParameter(id="file1", type_="File")]
    outputs = [
        cwl.CommandOutputParameter(
            id="output",
            type_="File",
            outputBinding=cwl.CommandOutputBinding(glob="output"),
        )
    ]
    cat_tool = cwl.CommandLineTool(
        inputs=inputs,
        outputs=outputs,
        cwlVersion="v1.2",
        baseCommand="cat",
        stdin="$(inputs.file1.path)",
        stdout="output",
    )
    yaml = ruamel.yaml.YAML()
    yaml.dump(cat_tool.save(), sys.stdout)


if __name__ == "__main__":
    main()