Skip to content

Commit

Permalink
Merge pull request #43 from mivek/fix/EmptyWind
Browse files Browse the repository at this point in the history
Update regex in MinimalVisibilityCommand and WindCommand
  • Loading branch information
mivek authored Mar 12, 2023
2 parents d4aaa2c + b78350a commit cc8fad3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [1.6.3] - 2023-03-12

### Fixed

- Parsing of token `0000KT` no longer causes an error.

## [1.6.2] - 2023-01-29

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions metar_taf_parser/command/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def execute(self, container: AbstractWeatherContainer, visibility_string: str):


class WindCommand:
regex = r'^(VRB|[0-3]\d{2})(\d{2})G?(\d{2})?(KT|MPS|KM\/H)?'
regex = r'^(VRB|00|[0-3]\d{2})(\d{2})G?(\d{2})?(KT|MPS|KM\/H)?'

def __init__(self):
self._pattern = re.compile(WindCommand.regex)
Expand Down Expand Up @@ -163,7 +163,7 @@ def can_parse(self, visibility_string: str):


class MinimalVisibilityCommand:
regex = r'^(\d{4}[a-z])$'
regex = r'^(\d{4}[NnEeSsWw])$'

def __init__(self):
self._pattern = re.compile(MinimalVisibilityCommand.regex)
Expand Down
9 changes: 9 additions & 0 deletions metar_taf_parser/tests/parser/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ def test_parse_runway_deposit(self):
self.assertEqual('03 mm', metar.runways_info[0].thickness)
self.assertEqual(_('DepositBrakingCapacity.default').format(0.35), metar.runways_info[0].braking_capacity)

def test_parse_empty_wind(self):

metar = MetarParser().parse('KATW 022045Z 0000KT 10SM SCT120 00/M08 A2996')

self.assertEqual('KATW', metar.station)
self.assertIsNotNone(metar.wind)
self.assertEqual(0, metar.wind.speed)
self.assertEqual(0, metar.wind._degrees)


class FunctionTestCase(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = metar-taf-parser-mivek
version = 1.6.2
version = 1.6.3
author = Jean-Kevin KPADEY
author_email = [email protected]
description = Python project parsing metar and taf message
Expand Down

0 comments on commit cc8fad3

Please sign in to comment.