Skip to content

Commit

Permalink
changed "#comment" to "# comment"
Browse files Browse the repository at this point in the history
  • Loading branch information
9FS committed Sep 22, 2023
1 parent d3190c5 commit ad0fbe0
Show file tree
Hide file tree
Showing 25 changed files with 607 additions and 608 deletions.
12 changes: 6 additions & 6 deletions src/DB_Type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
import enum


Expand All @@ -7,8 +7,8 @@ class DB_Type(enum.Enum):
Which database on \"https://ourairports.com/data/\"?
"""

aerodrome="https://ourairports.com/data/airports.csv" #aerodrome database
country ="https://ourairports.com/data/countries.csv" #country database for country names
frequency="https://ourairports.com/data/airport-frequencies.csv" #frequency database for information command
navaid ="https://ourairports.com/data/navaids.csv" #navaid database for information command
runway ="https://ourairports.com/data/runways.csv" #runway database for cross wind components and information command
aerodrome="https://ourairports.com/data/airports.csv" # aerodrome database
country ="https://ourairports.com/data/countries.csv" # country database for country names
frequency="https://ourairports.com/data/airport-frequencies.csv" # frequency database for information command
navaid ="https://ourairports.com/data/navaids.csv" # navaid database for information command
runway ="https://ourairports.com/data/runways.csv" # runway database for cross wind components and information command
2 changes: 1 addition & 1 deletion src/Doc_Type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
import enum


Expand Down
19 changes: 9 additions & 10 deletions src/Server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dataclasses
import discord


@dataclasses.dataclass
Expand All @@ -8,13 +7,13 @@ class Server:
all variables for 1 server instance
"""

id: int #discord server id
name: str #discord server name
id: int # discord server id
name: str # discord server name

channel_id: int|None=None #active channel id, needed later for subscription
command: str|None=None #active command, needed later for subscription
force_print: bool=True #force sending to discord (after user input request) or not (subscription)
METAR_o_previous: str|None=None #METAR previous for subscription
METAR_update_finished: bool=False #has program in subscription mode waited 1 round until source website refreshed METAR completely?
TAF_o_previous: str|None=None #TAF previous for subscription
TAF_update_finished: bool=False #has program in subscription mode waited 1 round until source website refreshed TAF completely?
channel_id: int|None=None # active channel id, needed later for subscription
command: str|None=None # active command, needed later for subscription
force_print: bool=True # force sending to discord (after user input request) or not (subscription)
METAR_o_previous: str|None=None # METAR previous for subscription
METAR_update_finished: bool=False # has program in subscription mode waited 1 round until source website refreshed METAR completely?
TAF_o_previous: str|None=None # TAF previous for subscription
TAF_update_finished: bool=False # has program in subscription mode waited 1 round until source website refreshed TAF completely?
6 changes: 3 additions & 3 deletions src/Station.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ class Station:
represents 1 aeronautical station (aerodrome)
"""

ICAO: str #station ICAO code
name: str|None=None #station name
elev: float|None=None #station elevation [m]
ICAO: str # station ICAO code
name: str|None=None # station name
elev: float|None=None # station elevation [m]
34 changes: 17 additions & 17 deletions src/change_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
import datetime as dt
import pandas
from change_format_.change import change_format_change
Expand All @@ -20,62 +20,62 @@


def change_format(info_list: list[str], i: int, station: Station, met_report_DT: dt.datetime, now_DT: dt.datetime, RWY_DB: pandas.DataFrame, server: Server) -> str:
#just forward station ICAO
# just forward station ICAO

info_new=change_format_met_report_DT(info_list[i], met_report_DT, now_DT, server) #met report time
info_new=change_format_met_report_DT(info_list[i], met_report_DT, now_DT, server) # met report time
if info_new!=None:
return info_new

info_new=change_format_wind (info_list[i], station, RWY_DB) #wind
info_new=change_format_wind (info_list[i], station, RWY_DB) # wind
if info_new!=None:
return info_new

info_new=change_format_vis (info_list, i) #visibility
info_new=change_format_vis (info_list, i) # visibility
if info_new!=None:
return info_new

info_new=change_format_RVR (info_list[i]) #RVR
info_new=change_format_RVR (info_list[i]) # RVR
if info_new!=None:
return info_new

info_new=change_format_weather (info_list, i) #weather, only mark weather dangerous
info_new=change_format_weather (info_list, i) # weather, only mark weather dangerous
if info_new!=None:
return info_new

info_new=change_format_clouds (info_list[i], station) #clouds
info_new=change_format_clouds (info_list[i], station) # clouds
if info_new!=None:
return info_new

info_new=change_format_VV (info_list[i]) #visibility vertical
info_new=change_format_VV (info_list[i]) # visibility vertical
if info_new!=None:
return info_new

info_new=change_format_temp_dew (info_list[i]) #temperature and dewpoint
info_new=change_format_temp_dew (info_list[i]) # temperature and dewpoint
if info_new!=None:
return info_new

info_new=change_format_QNH (info_list[i]) #QNH, altimeter setting
info_new=change_format_QNH (info_list[i]) # QNH, altimeter setting
if info_new!=None:
return info_new

info_new=change_format_RSM (info_list[i]) #runway state message
info_new=change_format_RSM (info_list[i]) # runway state message
if info_new!=None:
return info_new

info_new=change_format_change (info_list, i, met_report_DT) #trend and TAF: changes in weather
info_new=change_format_change (info_list, i, met_report_DT) # trend and TAF: changes in weather
if info_new!=None:
return info_new

info_new=change_format_validity (info_list[i], met_report_DT) #TAF: validity timespan
info_new=change_format_validity (info_list[i], met_report_DT) # TAF: validity timespan
if info_new!=None:
return info_new

info_new=change_format_TXTN (info_list[i], met_report_DT) #TAF: daily temperature max and min
info_new=change_format_TXTN (info_list[i], met_report_DT) # TAF: daily temperature max and min
if info_new!=None:
return info_new

info_new=change_format_USA_codes (info_list[i], met_report_DT, station, RWY_DB) #USA weather station machine codes
info_new=change_format_USA_codes (info_list[i], met_report_DT, station, RWY_DB) # USA weather station machine codes
if info_new!=None:
return info_new

return f" {info_list[i]}" #if format not found: just forward it
return f" {info_list[i]}" # if format not found: just forward it
6 changes: 3 additions & 3 deletions src/change_format_/HGT.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
from KFSconvert_to_SI import KFSconvert_to_SI
from KFSfstr import KFSfstr
import re
Expand All @@ -9,8 +9,8 @@ def change_format_HGT(info: str, station: Station) -> str|None:
re_match: re.Match|None


#RMK height
# RMK height
re_match=re.search("^(?P<HGT>[0-9]{1,4})FT$", info)
if re_match!=None:
HGT=int(re_match.groupdict()["HGT"])*KFSconvert_to_SI.LENGTH["ft"] #height [m]; tbh don't really know if it's a height, that's why no elevation used to calculate altitude
HGT=int(re_match.groupdict()["HGT"])*KFSconvert_to_SI.LENGTH["ft"] # height [m]; tbh don't really know if it's a height, that's why no elevation used to calculate altitude
return f" {KFSfstr.notation_abs(HGT, 2)}m"
26 changes: 13 additions & 13 deletions src/change_format_/QNH.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
import inspect
from KFSconvert_to_SI import KFSconvert_to_SI
from KFSfstr import KFSfstr
Expand All @@ -11,7 +11,7 @@ def change_format_QNH(info: str) -> str|None:
re_match: re.Match|None


#QNH [100Pa]
# QNH [100Pa]
re_match=re.search("^Q(?P<QNH>[0-9]{4})$", info)
if re_match!=None:
info_new: str
Expand All @@ -20,12 +20,12 @@ def change_format_QNH(info: str) -> str|None:

info_new=f"Q{KFSfstr.notation_abs(QNH*1e-3, 1, round_static=True, width=5)}kPa"

if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): #QNH unusual, because of possible altimeter settings and possible storms at low pressure
if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): # QNH unusual, because of possible altimeter settings and possible storms at low pressure
info_new=f"**{info_new}**"
return f" {info_new}"


#USA: altimeter setting [inHg]
# USA: altimeter setting [inHg]
re_match=re.search("^A(?P<QNH>[0-9]{4})$", info)
if re_match!=None:
info_new: str
Expand All @@ -34,12 +34,12 @@ def change_format_QNH(info: str) -> str|None:

info_new=f"A{KFSfstr.notation_abs(QNH*1e-3, 1, round_static=True, width=5)}kPa"

if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): #QNH unusual, because of possible altimeter settings and possible storms at low pressure
if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): # QNH unusual, because of possible altimeter settings and possible storms at low pressure
info_new=f"**{info_new}**"
return f" {info_new}"


#weird military base version [inHg]
# weird military base version [inHg]
re_match=re.search("^QNH(?P<QNH>[0-9]{4})INS$", info)
if re_match!=None:
info_new: str
Expand All @@ -48,12 +48,12 @@ def change_format_QNH(info: str) -> str|None:

info_new=f"A{KFSfstr.notation_abs(QNH*1e-3, 1, round_static=True, width=5)}kPa"

if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): #QNH unusual, because of possible altimeter settings and possible storms at low pressure
if ("QNH_min" in WEATHER_MIN and QNH<WEATHER_MIN["QNH_min"]) or ("QNH_max" in WEATHER_MIN and WEATHER_MIN["QNH_max"]<QNH): # QNH unusual, because of possible altimeter settings and possible storms at low pressure
info_new=f"**{info_new}**"
return f" {info_new}"


#russia: QFE [mmHg]
# russia: QFE [mmHg]
re_match=re.search("^QFE(?P<QFE>[0-9]{3}([.][0-9])?)$", info)
if re_match!=None:
info_new: str
Expand All @@ -65,7 +65,7 @@ def change_format_QNH(info: str) -> str|None:
return f" {info_new}"


#russia: QFE [mmHg] and [100Pa]
# russia: QFE [mmHg] and [100Pa]
re_match=re.search("^QFE[0-9]{3}/(?P<QFE>[0-9]{4})$", info)
if re_match!=None:
info_new: str
Expand All @@ -77,16 +77,16 @@ def change_format_QNH(info: str) -> str|None:
return f" {info_new}"


#USA: SLP [???]
# USA: SLP [???]
re_match=re.search("^SLP(?P<SLP>[0-9]{3})$", info)
if re_match!=None:
info_new: str
SLP: float #SLP [Pa]
SLP: float # SLP [Pa]

SLP=float(re_match.groupdict()['SLP'])*10
if 0<=SLP and SLP<5e3: #if 0kPa<=info<5kPa: +100kPa
if 0<=SLP and SLP<5e3: # if 0kPa<=info<5kPa: +100kPa
SLP+=100e3
elif SLP and SLP<10e3: #if 5kPa<=info<10kPa: +90kPa
elif SLP and SLP<10e3: # if 5kPa<=info<10kPa: +90kPa
SLP+=90e3
else:
logging.critical(f"SLP info *10 shoud be in [0; 10e3[, but it is {SLP}.")
Expand Down
20 changes: 10 additions & 10 deletions src/change_format_/RVR.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
# Copyright (c) 2023 구FS, all rights reserved. Subject to the CC BY-NC-SA 4.0 licence in `licence.md`.
import re
from KFSconvert_to_SI import KFSconvert_to_SI
from KFSfstr import KFSfstr
Expand All @@ -24,18 +24,18 @@ def change_format_RVR(info: str) -> str|None:
}


#RVR [m]
# RVR [m]
re_match=re.search("^R(?P<runway>[0-3][0-9]([LCR])?)/(?P<plus_minus>[PM]?)(?P<RVR_1>[0-9]{4})(V(?P<RVR_2>[0-9]{4}))?(?P<trend>[UND]?)$", info)
if re_match!=None:
info_new: str
plus_minus: str=PLUS_MINUS[re_match.groupdict()["plus_minus"]]
runway: str
RVR_1: float=float(re_match.groupdict()["RVR_1"])
RVR_2: float #RVR 2, if no given equal to RVR 1
trend: str=TREND[re_match.groupdict()["trend"]] #type:ignore
RVR_2: float # RVR 2, if no given equal to RVR 1
trend: str=TREND[re_match.groupdict()["trend"]] # type:ignore

runway=re_match.groupdict()["runway"]
if runway=="88": #if runway 88: all runways
if runway=="88": # if runway 88: all runways
runway=":ALL"
if re_match.groupdict()["RVR_2"]==None:
RVR_2=RVR_1
Expand All @@ -48,23 +48,23 @@ def change_format_RVR(info: str) -> str|None:
info_new+=f"V{KFSfstr.notation_tech(float(RVR_2), 2)}m"
info_new+=trend

if "RVR" in WEATHER_MIN and (RVR_1<WEATHER_MIN["RVR"] or RVR_2<WEATHER_MIN["RVR"]): #if a RVR below RVR min.: mark
if "RVR" in WEATHER_MIN and (RVR_1<WEATHER_MIN["RVR"] or RVR_2<WEATHER_MIN["RVR"]): # if a RVR below RVR min.: mark
info_new=f"**{info_new}**"
return f" {info_new}"


#USA: RVR [ft]
# USA: RVR [ft]
re_match=re.search("^R(?P<runway>[0-3][0-9]([LCR])?)/(?P<plus_minus>[PM]?)(?P<RVR_1>[0-9]{4})(V(?P<RVR_2>[0-9]{4}))?FT(/(?P<trend>[UND]))?$", info)
if re_match!=None:
info_new: str
plus_minus: str=PLUS_MINUS[re_match.groupdict()["plus_minus"]]
runway: str
RVR_1: float=float(re_match.groupdict()["RVR_1"])*KFSconvert_to_SI.LENGTH["ft"]
RVR_2: float #RVR 2, if no given equal to RVR 1
RVR_2: float # RVR 2, if no given equal to RVR 1
trend: str|None

runway=re_match.groupdict()["runway"]
if runway=="88": #if runway 88: all runways
if runway=="88": # if runway 88: all runways
runway=":ALL"
if re_match.groupdict()["RVR_2"]==None:
RVR_2=RVR_1
Expand All @@ -83,6 +83,6 @@ def change_format_RVR(info: str) -> str|None:
info_new+=f"V{KFSfstr.notation_tech(float(RVR_2), 2)}m"
info_new+=trend

if "RVR" in WEATHER_MIN and (RVR_1<WEATHER_MIN["RVR"] or RVR_2<WEATHER_MIN["RVR"]): #if a RVR below RVR min.: mark
if "RVR" in WEATHER_MIN and (RVR_1<WEATHER_MIN["RVR"] or RVR_2<WEATHER_MIN["RVR"]): # if a RVR below RVR min.: mark
info_new=f"**{info_new}**"
return f" {info_new}"
Loading

0 comments on commit ad0fbe0

Please sign in to comment.