How to use the metar.Datatypes.distance.legal_units function in metar

To help you get started, we’ve selected a few metar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-metar / python-metar / metar / Datatypes.py View on Github external
def __init__(self, value, units=None, gtlt=None):
        if not units:
            self._units = "M"
        else:
            if units.upper() not in distance.legal_units:
                raise UnitsError("unrecognized distance unit: '" + units + "'")
            self._units = units.upper()

        try:
            if value.startswith("M"):
                value = value[1:]
                gtlt = "<"
            elif value.startswith("P"):
                value = value[1:]
                gtlt = ">"
        except:
            pass
        if gtlt and gtlt not in distance.legal_gtlt:
            raise ValueError(
                "unrecognized greater-than/less-than symbol: '" + gtlt + "'"
            )