pyopensky 2.4__tar.gz → 2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyopensky
3
- Version: 2.4
3
+ Version: 2.5
4
4
  Summary: A Python interface for OpenSky database
5
5
  License: MIT
6
6
  Author: Xavier Olive
@@ -55,13 +55,16 @@ See details in the [documentation](https://open-aviation.github.io/pyopensky/cre
55
55
 
56
56
  ## Usage
57
57
 
58
+ > [!IMPORTANT]
59
+ > The Impala shell is now deprecated. Please upgrade to Trino.
60
+
58
61
  - from the [REST API](https://open-aviation.github.io/pyopensky/rest.html):
59
62
 
60
63
  ```python
61
64
  from pyopensky.rest import REST
62
-
65
+
63
66
  rest = REST()
64
-
67
+
65
68
  rest.states()
66
69
  rest.tracks(icao24)
67
70
  rest.routes(callsign)
@@ -69,25 +72,16 @@ See details in the [documentation](https://open-aviation.github.io/pyopensky/cre
69
72
  rest.arrival(airport, begin, end)
70
73
  rest.departure(airport, begin, end)
71
74
  ```
72
- - from the [Impala](https://open-aviation.github.io/pyopensky/impala.html) shell (requires authentication):
73
75
 
74
- ```python
75
- from pyopensky.impala import Impala
76
-
77
- impala = Impala()
78
- # full description of the whole set of parameters in the documentation
79
- impala.flightlist(start, stop, *, airport, callsign, icao24)
80
- impala.history(start, stop, *, callsign, icao24, bounds)
81
- impala.rawdata(start, stop, *, callsign, icao24, bounds)
82
- ```
83
76
  - from the [Trino](https://open-aviation.github.io/pyopensky/trino.html) database (requires authentication):
84
77
 
85
78
  ```python
86
79
  from pyopensky.trino import Trino
87
-
80
+
88
81
  trino = Trino()
89
82
  # full description of the whole set of parameters in the documentation
90
83
  trino.flightlist(start, stop, *, airport, callsign, icao24)
91
84
  trino.history(start, stop, *, callsign, icao24, bounds)
92
85
  trino.rawdata(start, stop, *, callsign, icao24, bounds)
93
86
  ```
87
+
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyopensky"
3
- version = "2.4"
3
+ version = "2.5"
4
4
  description = "A Python interface for OpenSky database"
5
5
  authors = ["Xavier Olive <git@xoolive.org>", "Junzi Sun <j.sun-1@tudelft.nl>"]
6
6
  license = "MIT"
@@ -30,13 +30,16 @@ See details in the [documentation](https://open-aviation.github.io/pyopensky/cre
30
30
 
31
31
  ## Usage
32
32
 
33
+ > [!IMPORTANT]
34
+ > The Impala shell is now deprecated. Please upgrade to Trino.
35
+
33
36
  - from the [REST API](https://open-aviation.github.io/pyopensky/rest.html):
34
37
 
35
38
  ```python
36
39
  from pyopensky.rest import REST
37
-
40
+
38
41
  rest = REST()
39
-
42
+
40
43
  rest.states()
41
44
  rest.tracks(icao24)
42
45
  rest.routes(callsign)
@@ -44,25 +47,15 @@ See details in the [documentation](https://open-aviation.github.io/pyopensky/cre
44
47
  rest.arrival(airport, begin, end)
45
48
  rest.departure(airport, begin, end)
46
49
  ```
47
- - from the [Impala](https://open-aviation.github.io/pyopensky/impala.html) shell (requires authentication):
48
50
 
49
- ```python
50
- from pyopensky.impala import Impala
51
-
52
- impala = Impala()
53
- # full description of the whole set of parameters in the documentation
54
- impala.flightlist(start, stop, *, airport, callsign, icao24)
55
- impala.history(start, stop, *, callsign, icao24, bounds)
56
- impala.rawdata(start, stop, *, callsign, icao24, bounds)
57
- ```
58
51
  - from the [Trino](https://open-aviation.github.io/pyopensky/trino.html) database (requires authentication):
59
52
 
60
53
  ```python
61
54
  from pyopensky.trino import Trino
62
-
55
+
63
56
  trino = Trino()
64
57
  # full description of the whole set of parameters in the documentation
65
58
  trino.flightlist(start, stop, *, airport, callsign, icao24)
66
59
  trino.history(start, stop, *, callsign, icao24, bounds)
67
60
  trino.rawdata(start, stop, *, callsign, icao24, bounds)
68
- ```
61
+ ```
@@ -119,6 +119,8 @@ class Trino(OpenSkyDBAPI):
119
119
  if token is not None
120
120
  else OAuth2Authentication(),
121
121
  http_scheme="https",
122
+ # https://github.com/trinodb/trino-python-client/discussions/456
123
+ legacy_prepared_statements=True,
122
124
  ),
123
125
  )
124
126
  return engine
@@ -384,6 +386,7 @@ class Trino(OpenSkyDBAPI):
384
386
  cached: bool = True,
385
387
  compress: bool = False,
386
388
  limit: None | int = None,
389
+ selected_columns: tuple[InstrumentedAttribute[Any] | str, ...] = (),
387
390
  **kwargs: Any,
388
391
  ) -> None | pd.DataFrame:
389
392
  """Get Traffic from the OpenSky Trino database.
@@ -413,6 +416,10 @@ class Trino(OpenSkyDBAPI):
413
416
  :param bounds: sets a geographical footprint. Either an **airspace or
414
417
  shapely shape** (requires the bounds attribute); or a **tuple of
415
418
  float** (west, south, east, north);
419
+ :param selected_columns: specify the columns you want to retrieve. When
420
+ empty, use all columns of the StateVectorsData4 table. You may
421
+ escape column names as str. **Always** escape names from the
422
+ FlightsData4 table.
416
423
 
417
424
  **Airports**
418
425
 
@@ -475,7 +482,7 @@ class Trino(OpenSkyDBAPI):
475
482
  )
476
483
  .where(
477
484
  FlightsData4.day >= start_ts.floor("1d"),
478
- FlightsData4.day <= start_ts.ceil("1d"),
485
+ FlightsData4.day <= stop_ts.ceil("1d"),
479
486
  )
480
487
  )
481
488
 
@@ -568,10 +575,31 @@ class Trino(OpenSkyDBAPI):
568
575
  stmt = stmt.where(
569
576
  StateVectorsData4.time >= start_ts,
570
577
  StateVectorsData4.time <= stop_ts,
571
- StateVectorsData4.hour >= start_ts.floor("1H"),
572
- StateVectorsData4.hour < stop_ts.ceil("1H"),
578
+ StateVectorsData4.hour >= start_ts.floor("1h"),
579
+ StateVectorsData4.hour < stop_ts.ceil("1h"),
573
580
  )
574
581
 
582
+ def transform_column(col: str) -> InstrumentedAttribute[Any]:
583
+ if "." in col:
584
+ table, column = col.split(".")
585
+ MATCH = {
586
+ "StateVectorsData4": StateVectorsData4,
587
+ "FlightsData4": fd4,
588
+ }
589
+ return getattr(MATCH[table], column) # type: ignore
590
+ if candidate := getattr(StateVectorsData4, col, None):
591
+ return candidate # type: ignore
592
+ if candidate := getattr(fd4, col, None):
593
+ return candidate # type: ignore
594
+ raise ValueError(f"Unknown column: {col}")
595
+
596
+ if len(selected_columns) > 0:
597
+ columns = (
598
+ transform_column(col) if isinstance(col, str) else col
599
+ for col in selected_columns
600
+ )
601
+ stmt = stmt.with_only_columns(*columns)
602
+
575
603
  if limit is not None:
576
604
  stmt = stmt.limit(limit)
577
605
 
@@ -712,7 +740,7 @@ class Trino(OpenSkyDBAPI):
712
740
  )
713
741
  .where(
714
742
  FlightsData4.day >= start_ts.floor("1d"),
715
- FlightsData4.day <= start_ts.ceil("1d"),
743
+ FlightsData4.day <= stop_ts.ceil("1d"),
716
744
  )
717
745
  )
718
746
 
@@ -766,8 +794,8 @@ class Trino(OpenSkyDBAPI):
766
794
  )
767
795
  .group_by(StateVectorsData4.icao24)
768
796
  .where(
769
- StateVectorsData4.hour >= start_ts.floor("1H"),
770
- StateVectorsData4.hour <= stop_ts.ceil("1H"),
797
+ StateVectorsData4.hour >= start_ts.floor("1h"),
798
+ StateVectorsData4.hour <= stop_ts.ceil("1h"),
771
799
  StateVectorsData4.time >= start_ts,
772
800
  StateVectorsData4.time <= stop_ts,
773
801
  )
@@ -819,8 +847,8 @@ class Trino(OpenSkyDBAPI):
819
847
  stmt = stmt.where(
820
848
  Table.mintime >= start_ts,
821
849
  Table.mintime <= stop_ts,
822
- Table.hour >= start_ts.floor("1H"),
823
- Table.hour < stop_ts.ceil("1H"),
850
+ Table.hour >= start_ts.floor("1h"),
851
+ Table.hour < stop_ts.ceil("1h"),
824
852
  )
825
853
 
826
854
  if limit is not None:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes