File tree Expand file tree Collapse file tree 1 file changed +26
-22
lines changed Expand file tree Collapse file tree 1 file changed +26
-22
lines changed Original file line number Diff line number Diff line change @@ -123,30 +123,9 @@ async def states(self, bounding_box: BoundingBox | None = None) -> StatesRespons
123123
124124 data = await self ._request ("states/all" , data = params )
125125
126- keys = [
127- "icao24" ,
128- "callsign" ,
129- "origin_country" ,
130- "time_position" ,
131- "last_contact" ,
132- "longitude" ,
133- "latitude" ,
134- "baro_altitude" ,
135- "on_ground" ,
136- "velocity" ,
137- "true_track" ,
138- "vertical_rate" ,
139- "sensors" ,
140- "geo_altitude" ,
141- "squawk" ,
142- "spi" ,
143- "position_source" ,
144- "category" ,
145- ]
146-
147126 data = {
148127 ** data ,
149- "states" : [dict ( zip ( keys , state , strict = True ) ) for state in data ["states" ]],
128+ "states" : [self . _convert_state ( state ) for state in data ["states" ]],
150129 }
151130
152131 self ._register_credit_usage (credit_cost )
@@ -180,6 +159,31 @@ def remaining_credits(self) -> int:
180159 )
181160 return self .opensky_credits - used_credits
182161
162+ @staticmethod
163+ def _convert_state (state : list [Any ]) -> dict [str , Any ]:
164+ keys = [
165+ "icao24" ,
166+ "callsign" ,
167+ "origin_country" ,
168+ "time_position" ,
169+ "last_contact" ,
170+ "longitude" ,
171+ "latitude" ,
172+ "baro_altitude" ,
173+ "on_ground" ,
174+ "velocity" ,
175+ "true_track" ,
176+ "vertical_rate" ,
177+ "sensors" ,
178+ "geo_altitude" ,
179+ "squawk" ,
180+ "spi" ,
181+ "position_source" ,
182+ "category" ,
183+ ]
184+
185+ return dict (zip (keys , state , strict = True ))
186+
183187 async def close (self ) -> None :
184188 """Close open client session."""
185189 if self .session and self ._close_session :
You can’t perform that action at this time.
0 commit comments