:mod:`weaver.formats` ===================== .. py:module:: weaver.formats Module Contents --------------- .. data:: CONTENT_TYPE_APP_FORM :annotation: = application/x-www-form-urlencoded .. data:: CONTENT_TYPE_APP_NETCDF :annotation: = application/x-netcdf .. data:: CONTENT_TYPE_APP_GZIP :annotation: = application/gzip .. data:: CONTENT_TYPE_APP_HDF5 :annotation: = application/x-hdf5 .. data:: CONTENT_TYPE_APP_TAR :annotation: = application/x-tar .. data:: CONTENT_TYPE_APP_ZIP :annotation: = application/zip .. data:: CONTENT_TYPE_TEXT_HTML :annotation: = text/html .. data:: CONTENT_TYPE_TEXT_PLAIN :annotation: = text/plain .. data:: CONTENT_TYPE_APP_PDF :annotation: = application/pdf .. data:: CONTENT_TYPE_APP_JSON :annotation: = application/json .. data:: CONTENT_TYPE_APP_XML :annotation: = application/xml .. data:: CONTENT_TYPE_TEXT_XML :annotation: = text/xml .. data:: CONTENT_TYPE_ANY_XML .. data:: _CONTENT_TYPE_EXTENSION_MAPPING .. function:: get_extension(mime_type) -> AnyStr Retrieves the extension corresponding to ``mime_type`` if explicitly defined, or by simple parsing otherwise. .. data:: IANA_NAMESPACE :annotation: = iana .. data:: IANA_NAMESPACE_DEFINITION .. data:: EDAM_NAMESPACE :annotation: = edam .. data:: EDAM_NAMESPACE_DEFINITION .. data:: EDAM_SCHEMA :annotation: = http://edamontology.org/EDAM_1.21.owl .. data:: EDAM_MAPPING .. data:: FORMAT_NAMESPACES .. function:: get_cwl_file_format(mime_type, make_reference=False, must_exist=False) -> Union[Tuple[Union[JSON, None], Union[AnyStr, None]], Union[AnyStr, None]] Obtains the corresponding `IANA`/`EDAM` ``format`` value to be applied under a `CWL` I/O ``File`` from the ``mime_type`` (`Content-Type` header) using the first matched one. If ``make_reference=False``: - If there is a match, returns ``tuple({}, )``: 1) corresponding namespace mapping to be applied under ``$namespaces`` in the `CWL`. 2) value of ``format`` adjusted according to the namespace to be applied to ``File`` in the `CWL`. - If there is no match but ``must_exist=False``: returns a literal and non-existing definition as ``tuple({"iana": }, )`` - Otherwise, returns ``(None, None)`` If ``make_reference=True``: - If there is a match, returns the explicit format reference as ``/``. - If there is no match but ``must_exist=False``, returns the literal reference as ``/``. - Otherwise, returns a single ``None``. .. note:: In situations where ``must_exist=False`` and the default non-existing namespace is returned, the `CWL` behaviour is to evaluate corresponding ``format`` for literal matching strings. .. function:: clean_mime_type_format(mime_type) -> AnyStr Removes any additional namespace key or URL from ``mime_type`` so that it corresponds to the generic representation (ex: `application/json`) instead of the ``:`` variant used in `CWL->inputs/outputs->File->format`.