weaver.formats
¶
Module Contents¶
-
weaver.formats.
get_extension
(mime_type) → AnyStr[source]¶ Retrieves the extension corresponding to
mime_type
if explicitly defined, or by simple parsing otherwise.
-
weaver.formats.
get_cwl_file_format
(mime_type, make_reference=False, must_exist=False) → Union[Tuple[Union[JSON, None], Union[AnyStr, None]], Union[AnyStr, None]][source]¶ Obtains the corresponding IANA/EDAM
format
value to be applied under a CWL I/OFile
from themime_type
(Content-Type header) using the first matched one.- If
make_reference=False
: - If there is a match, returns
tuple({<namespace-name: namespace-url>}, <format>)
: - corresponding namespace mapping to be applied under
$namespaces
in the CWL. - value of
format
adjusted according to the namespace to be applied toFile
in the CWL.
- corresponding namespace mapping to be applied under
- If there is a match, returns
- If there is no match but
must_exist=False
: - returns a literal and non-existing definition as
tuple({"iana": <iana-url>}, <format>)
- If there is no match but
- Otherwise, returns
(None, None)
- If
make_reference=True
: - If there is a match, returns the explicit format reference as
<namespace-url>/<format>
. - If there is no match but
must_exist=False
, returns the literal reference as<iana-url>/<format>
. - Otherwise, returns a single
None
.
- If there is a match, returns the explicit format reference as
Note
In situations where
must_exist=False
and the default non-existing namespace is returned, the CWL behaviour is to evaluate correspondingformat
for literal matching strings.- If