Skip to content

Cache

cache ¤

A simple file-based cache.

Classes:

Name Description
FR24Cache
  • flight_list/{kind}/{ident}
FlightListBy
Collection

A directory containing scannable files.

File

Attributes:

Name Type Description
PATH_CACHE
Ident TypeAlias

The identifier for the cached file.

PATH_CACHE module-attribute ¤

PATH_CACHE = Path(user_cache_dir('fr24'))

Ident module-attribute ¤

Ident: TypeAlias = Union[str, int]

The identifier for the cached file.

FR24Cache ¤

FR24Cache(path: Path | str)
  • flight_list/{kind}/{ident}
  • playback/{flight_id}
  • feed/{timestamp}
  • nearest_flights/{lon}_{lat}_{timestamp}
  • live_flights_status/{timestamp}
  • top_flights/{timestamp}
  • flight_details/{flight_id}_{timestamp}
  • playback_flight/{flight_id}_{timestamp}

Methods:

Name Description
default

Create a cache in the default directory.

Attributes:

Name Type Description
path
flight_list
playback
live_feed
nearest_flights
live_flights_status
top_flights
flight_details
playback_flight

path instance-attribute ¤

path = Path(path)

flight_list instance-attribute ¤

flight_list = FlightListBy(
    reg=Collection(flight_list_dir / "reg"),
    flight=Collection(flight_list_dir / "flight"),
)

playback instance-attribute ¤

playback = Collection(path / 'playback')

live_feed instance-attribute ¤

live_feed = Collection(path / 'feed')

nearest_flights instance-attribute ¤

nearest_flights = Collection(path / 'nearest_flights')

live_flights_status instance-attribute ¤

live_flights_status = Collection(
    path / "live_flights_status"
)

top_flights instance-attribute ¤

top_flights = Collection(path / 'top_flights')

flight_details instance-attribute ¤

flight_details = Collection(path / 'flight_details')

playback_flight instance-attribute ¤

playback_flight = Collection(path / 'playback_flight')

default classmethod ¤

default() -> FR24Cache

Create a cache in the default directory.

FlightListBy dataclass ¤

FlightListBy(reg: Collection, flight: Collection)

Methods:

Name Description
__call__

Attributes:

Name Type Description
reg Collection

Collection of flight lists by registration number.

flight Collection

Collection of flight lists by flight number.

reg instance-attribute ¤

Collection of flight lists by registration number.

flight instance-attribute ¤

flight: Collection

Collection of flight lists by flight number.

__call__ ¤

__call__(kind: Literal['reg', 'flight']) -> Collection

Collection dataclass ¤

Collection(path: Path)

A directory containing scannable files.

Methods:

Name Description
glob

Iterate over this collection and yield all scannable files matching

scan_table

Lazily load a file from this collection.

new_bare_path

Returns the bare path (without the file extension) to the file in this

Attributes:

Name Type Description
path Path

path instance-attribute ¤

path: Path

glob ¤

glob(pattern: str) -> Generator[File, None, None]

Iterate over this collection and yield all scannable files matching the given relative pattern.

scan_table ¤

scan_table(
    ident: File | Path | Ident,
    *,
    format: SupportedFormats = "parquet",
) -> LazyFrame

Lazily load a file from this collection.

Parameters:

Name Type Description Default
ident File | Path | Ident

The path to the file to scan, or the identifier of the record in the collection: - cache.flight_list.reg.scan_table: Registration number, uppercase - cache.flight_list.flight.scan_table: Flight number, upper cased - cache.playback.scan_table: Flight id, hex representation, uppercase - cache.feed.scan_table: Unix timestamp, integer seconds since epoch - cache.nearest_flights.scan_table: f"{int(longitude * 1e6)}_{int(latitude * 1e6)}_{timestamp}", where longitude and latitude are the coordinates in degrees, and timestamp is the integer seconds since epoch - cache.live_flights_status.scan_table: Unix timestamp, integer seconds since epoch - cache.top_flights.scan_table: Unix timestamp, integer seconds since epoch - cache.flight_details.scan_table: f"{flight_id}_{timestamp}", where flight_id is the flight ID (hex representation, uppercase) and timestamp is the integer seconds since epoch - cache.playback_flight.scan_table: f"{flight_id}_{timestamp}", where flight_id is the flight ID (hex representation, uppercase) and timestamp is actual time of departure, in integer seconds since epoch

required

new_bare_path ¤

new_bare_path(ident: str) -> BarePath

Returns the bare path (without the file extension) to the file in this collection.

File ¤

Bases: Path

Methods:

Name Description
scan

Lazily load this file.

Attributes:

Name Type Description
format SupportedFormats

format property ¤

scan ¤

scan() -> LazyFrame

Lazily load this file.