From cfdcb7784cf2303b376d526071b9ab14363cabb8 Mon Sep 17 00:00:00 2001 From: Clarmy Lee Date: Wed, 8 Oct 2025 13:59:23 +0800 Subject: [PATCH 1/4] chore: update version handling and add new test case for calm wind condition --- .gitignore | 4 +++- pymetaf/__init__.py | 4 +++- pymetaf/parser.py | 6 ++++++ setup.py | 12 ++++++++++-- tests/case/metar/parse_text_case.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 58e4756..f847725 100644 --- a/.gitignore +++ b/.gitignore @@ -127,4 +127,6 @@ dmypy.json # Pyre type checker .pyre/ -*.csv \ No newline at end of file +*.csv + +.DS_Store \ No newline at end of file diff --git a/pymetaf/__init__.py b/pymetaf/__init__.py index bd753cc..b04c1c7 100644 --- a/pymetaf/__init__.py +++ b/pymetaf/__init__.py @@ -1 +1,3 @@ -from .parser import * +__version__ = '0.1.3' + +from .parser import * \ No newline at end of file diff --git a/pymetaf/parser.py b/pymetaf/parser.py index 97c000f..3b94113 100644 --- a/pymetaf/parser.py +++ b/pymetaf/parser.py @@ -254,6 +254,12 @@ def parse_text(text, year, month): wd = int(wd_str) ws = int(wdws[3:5]) # wind speed + + # If wind speed is 0 and wind direction is 000, this is calm wind (静风) + # In this case, wind direction should be None + if ws == 0 and wd_str == "000": + wd = None + if wdws[5] == "G": # Example with gust: METAR ZBXH 250700Z 25008G13MPS 9999 FEW040 13/M18 Q1015 NOSIG gust = int(wdws[6:8]) # gust diff --git a/setup.py b/setup.py index ff06190..4186d1e 100644 --- a/setup.py +++ b/setup.py @@ -10,11 +10,19 @@ with open(requirements_path) as f: required = f.read().splitlines() +# 从 pymetaf/__init__.py 读取版本号 +version = {} +with open(os.path.join(FILE_PATH, "pymetaf", "__init__.py")) as f: + for line in f: + if line.startswith("__version__"): + exec(line, version) + break + setuptools.setup( name="pymetaf", - version="1.0.3", + version=version["__version__"], author="Wentao Li", - author_email="wentao.li@moji.com", + author_email="clarmyleewt@outlook.com", description="A python package for parsing metar & taf raw text", long_description=long_description, long_description_content_type="text/markdown", diff --git a/tests/case/metar/parse_text_case.py b/tests/case/metar/parse_text_case.py index 38c6ae1..7dd44f4 100644 --- a/tests/case/metar/parse_text_case.py +++ b/tests/case/metar/parse_text_case.py @@ -633,4 +633,33 @@ "auto": False, }, }, + { + "kwargs": { + "text": "METAR ZBAA 301630Z 00000MPS CAVOK 16/16 Q1009 NOSIG=", + "year": 2025, + "month": 10, + }, + "result": { + "kind": "METAR", + "icao": "ZBAA", + "auto": False, + "datetime": "2025-10-30T16:30:00+00:00", + "wind_direction": None, + "wind_direction_units": "degree", + "wind_speed": 0, + "wind_speed_units": "m/s", + "gust": None, + "wind_direction_range": None, + "cavok": True, + "visibility": 99999, + "visibility_units": "m", + "temperature": 16, + "dew_temperature": 16, + "temperature_units": "degree C", + "qnh": 1009, + "qnh_units": "hPa", + "cloud": None, + "weather": ["Clear Sky"], + }, + }, ] From bbef38cbed73f15fa55fc609706dd56d504beeb3 Mon Sep 17 00:00:00 2001 From: Clarmy Lee Date: Wed, 8 Oct 2025 13:59:53 +0800 Subject: [PATCH 2/4] chore: standardize version string quotes and clean up whitespace in parser --- pymetaf/__init__.py | 4 ++-- pymetaf/parser.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pymetaf/__init__.py b/pymetaf/__init__.py index b04c1c7..71d2844 100644 --- a/pymetaf/__init__.py +++ b/pymetaf/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.1.3' +__version__ = "0.1.3" -from .parser import * \ No newline at end of file +from .parser import * diff --git a/pymetaf/parser.py b/pymetaf/parser.py index 3b94113..012f595 100644 --- a/pymetaf/parser.py +++ b/pymetaf/parser.py @@ -254,12 +254,12 @@ def parse_text(text, year, month): wd = int(wd_str) ws = int(wdws[3:5]) # wind speed - + # If wind speed is 0 and wind direction is 000, this is calm wind (静风) # In this case, wind direction should be None if ws == 0 and wd_str == "000": wd = None - + if wdws[5] == "G": # Example with gust: METAR ZBXH 250700Z 25008G13MPS 9999 FEW040 13/M18 Q1015 NOSIG gust = int(wdws[6:8]) # gust @@ -298,9 +298,9 @@ def parse_text(text, year, month): visstr = get_field_text("vis", no_trend_text) if visstr: if visstr == "9999": - dataset[ - "visibility" - ] = 99999 # Represent visibility greater than 10000 as 99999 + dataset["visibility"] = ( + 99999 # Represent visibility greater than 10000 as 99999 + ) elif visstr == "0000": dataset["visibility"] = 50 elif visstr.endswith("SM"): From 658a8449c05fb0ce2bd506b0f8723448faffd6c1 Mon Sep 17 00:00:00 2001 From: Clarmy Lee Date: Wed, 8 Oct 2025 14:02:12 +0800 Subject: [PATCH 3/4] chore: bump version to 0.1.4 --- pymetaf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymetaf/__init__.py b/pymetaf/__init__.py index 71d2844..6e838a7 100644 --- a/pymetaf/__init__.py +++ b/pymetaf/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.1.3" +__version__ = "0.1.4" from .parser import * From a3715bc32818a09c3c781a895eda13a508d65491 Mon Sep 17 00:00:00 2001 From: Clarmy Lee Date: Wed, 8 Oct 2025 14:03:06 +0800 Subject: [PATCH 4/4] chore: add Python 3.11 and 3.12 to workflow matrix --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e1dad6f..bbb9b25 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3