示例#1
0
def process_attrib_metar(attrib: etree) -> MetarSkyConditionXML:
    """
    Parse XML attributes of Metar data.

    :param attrib: The attribute to be parsed.
    :return: Class containing the relevant attribute data.
    """
    att_class = {
        'sky_condition': MetarSkyConditionXML,
    }
    if attrib.tag not in att_class.keys():
        raise ValueError()
    return att_class[attrib.tag](**{k: v for k, v in attrib.items()})
示例#2
0
def process_attrib(
    attrib: etree
) -> Union[SkyConditionXML, TurbulenceConditionXML, IcingConditionXML]:
    """
    Parse XML attributes of Taf data.

    :param attrib: The XML attribute to be parsed.
    :return: Class containing relevant attribute data.
    """
    att_class = {
        'sky_condition': SkyConditionXML,
        'turbulence_condition': TurbulenceConditionXML,
        'icing_condition': IcingConditionXML,
    }
    if attrib.tag not in att_class.keys():
        raise ValueError()
    return att_class[attrib.tag](**{k: v for k, v in attrib.items()})