Skip to content

Commit

Permalink
simplify taf encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgryan committed Nov 12, 2024
1 parent c65587c commit 31d3863
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/detaf/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@ class TAF:
issue_time: str = None
weather_conditions: list[WeatherCondition] = field(default_factory=list)

def taf_encode(self) -> str:
parts = ["TAF"]
if self.version != Version.ORIGINAL:
parts.append(self.version.taf_encode())
if self.icao_identifier:
parts.append(self.icao_identifier)
if self.issue_time:
parts.append(encode_issue_time(self.issue_time))
for weather in self.weather_conditions:
parts.append(weather.taf_encode())
return " ".join(parts)

def __iter__(self):
yield "TAF"
if self.version != Version.ORIGINAL:
Expand All @@ -113,6 +101,9 @@ def __iter__(self):
yield self.issue_time
yield from self.weather_conditions

def taf_encode(self) -> str:
return " ".join(encode(item) for item in self)


def parse(bulletin: str) -> TAF:
words = bulletin.strip().split()
Expand Down

0 comments on commit 31d3863

Please sign in to comment.