cwl_utils.utils =============== .. py:module:: cwl_utils.utils .. autoapi-nested-parse:: Miscellaneous utility functions. Attributes ---------- .. autoapisummary:: cwl_utils.utils.fast_yaml Functions --------- .. autoapisummary:: cwl_utils.utils.bytes2str_in_dicts cwl_utils.utils.load_linked_file cwl_utils.utils.normalize_to_map cwl_utils.utils.normalize_to_list cwl_utils.utils.resolved_path cwl_utils.utils.singularity_supports_userns cwl_utils.utils.yaml_dumps cwl_utils.utils.to_pascal_case cwl_utils.utils.sanitise_schema_field cwl_utils.utils.is_uri cwl_utils.utils.is_local_uri cwl_utils.utils.get_value_from_uri Module Contents --------------- .. py:data:: fast_yaml .. py:function:: bytes2str_in_dicts(inp) Convert any present byte string to unicode string, inplace. input is a dict of nested dicts and lists .. py:function:: load_linked_file(base_url, link, is_import = False) From https://github.com/rabix/sbpack/blob/b8404a0859ffcbe1edae6d8f934e51847b003320/sbpack/lib.py . .. py:function:: normalize_to_map(obj, key_field) From https://github.com/rabix/sbpack/blob/b8404a0859ffcbe1edae6d8f934e51847b003320/sbpack/lib.py . .. py:function:: normalize_to_list(obj, key_field, value_field) From https://github.com/rabix/sbpack/blob/b8404a0859ffcbe1edae6d8f934e51847b003320/sbpack/lib.py . .. py:function:: resolved_path(base_url, link) Derive a resolved path. This function will 1. Resolve the path, which means dot and double dot components are resolved 2. Use the OS appropriate path resolution for local paths, and network appropriate resolution for network paths From https://github.com/rabix/sbpack/blob/b8404a0859ffcbe1edae6d8f934e51847b003320/sbpack/lib.py :param base_url: "this document" :param link: "string in this document" :returns: new URL that allows us to retrieve the linked document .. py:function:: singularity_supports_userns() Confirm if the version of Singularity install supports the --userns flag. .. py:function:: yaml_dumps(obj) Shortcut. Don't use if you have a file descriptor (like sys.stdout) available. .. py:function:: to_pascal_case(name) Convert a string to PascalCase. fastq-list-row to FastqListRow fastq_list_row to FastqListRow :param name: :return: .. py:function:: sanitise_schema_field(schema_field_item) Schemas need to be resolved before converted to JSON properties. Convert .. code:: python { 'type': 'Directory?' } To .. code:: python { 'type': ['null', 'Directory'] } Convert .. code:: python { 'type': 'string[]' } To .. code:: python InputArraySchema( type_=array, items=string ) Convert .. code:: python { 'type': 'File[]?' } To .. code:: python { 'type': [ 'null', InputArraySchema( type_=array, items=File ) ] } Convert .. code:: python { 'type': 'Enum', 'symbols': ['A', 'B', 'C'] } To .. code:: python { 'type': InputEnumSchema( type_=enum, symbols=['A', 'B', 'C'] ) } Convert .. code:: python { 'type': 'array', 'items': { '$import': '../../../schemas/fastq-list-row/1.0.0/fastq-list-row__1.0.0.yaml#fastq-list-row' } } To .. code:: python { 'type': InputArraySchema( type_=array, items={ '$import': '../../../schemas/fastq-list-row/1.0.0/fastq-list-row__1.0.0.yaml#fastq-list-row' } ) } :param schema_field_item: :return: .. py:function:: is_uri(uri) Given a URI return True if it is a URI. :param uri: :return: .. py:function:: is_local_uri(uri) Given a uri, first check if it is a uri, then check if it is a local uri. .. py:function:: get_value_from_uri(uri) Given a URI, return the value after #. file://path/to/imported/record#my_workflow_name/record_name Returns record_name :param uri: :return: