pymetkit.pymetkit_batch ======================= .. py:module:: pymetkit.pymetkit_batch .. autoapi-nested-parse:: Bulk operations over :class:`~pymetkit.MarsRequest` objects. Functions --------- .. autoapisummary:: pymetkit.pymetkit_batch.parse_mars_request pymetkit.pymetkit_batch.expand Module Contents --------------- .. py:function:: parse_mars_request(file_or_str: IO | str, strict: bool = False) -> list[pymetkit.pymetkit.MarsRequest] Parse one or more MARS requests from a string or file-like object. :param file_or_str: MARS request text, or an open file containing it. :type file_or_str: str | IO :param strict: If True, raise on invalid values instead of discarding them. :type strict: bool :returns: The parsed requests, in the order they appear in the input. :rtype: list[MarsRequest] :raises MetKitException: If the input cannot be parsed. .. py:function:: expand(mars_requests: list[MarsRequest] | MarsRequest, inherit: bool = True, strict: bool = False) -> list[MarsRequest] | MarsRequest Expand one or more requests against the MARS language definition. Internal language checks are performed once for the whole batch rather than once per request. Pass a list whenever expanding more than one request. A single :class:`MarsRequest` may also be passed directly; the return type matches the input shape. :param mars_requests: The request or requests to expand. :type mars_requests: MarsRequest | list[MarsRequest] :param inherit: If True, populate the result with default values for missing parameters. :type inherit: bool :param strict: If True, raise on invalid values instead of issuing a warning. :type strict: bool :returns: The expanded request(s). A single input returns a single output. :rtype: MarsRequest | list[MarsRequest] :raises MetKitException: If a request is incompatible with the MARS language definition. .. rubric:: Examples >>> requests = [ ... MarsRequest("retrieve", {"class": "od", "date": "-1", "param": "130"}), ... MarsRequest("retrieve", {"class": "od", "date": "-1", "param": "131"}), ... ] >>> expanded = expand(requests) >>> len(expanded) 2