Base Downloader¶
BaseGTFSDownloader ¶
Bases: ABC
Abstract base class for a GTFS catalog/source downloader client.
Subclasses must implement search_feeds(). download_feeds() is
shared across all sources and downloads whatever GTFSFeedMetadata
list is passed to it.
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
The API key used to authenticate with the source, or None if the source requires no authentication. |
Initialize the downloader with an API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
Optional[str]
|
API key for the source. If not provided, it is
resolved via |
None
|
Source code in pyGTFSHandler/downloaders/base.py
search_feeds
abstractmethod
¶
Search the source's catalog for GTFS feeds.
Returns:
| Type | Description |
|---|---|
List[GTFSFeedMetadata]
|
A list of |
Source code in pyGTFSHandler/downloaders/base.py
download_feeds ¶
download_feeds(feeds: List[GTFSFeedMetadata], download_folder: str, overwrite: bool = False, unzip: bool = True) -> List[str]
Download previously found feeds to a local folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feeds
|
List[GTFSFeedMetadata]
|
Feeds to download, as returned by |
required |
download_folder
|
str
|
Directory to store (and, if |
required |
overwrite
|
bool
|
If True, re-download and replace files that already exist on disk. |
False
|
unzip
|
bool
|
If True, extract each ZIP after downloading and delete the ZIP file. |
True
|
Returns:
| Type | Description |
|---|---|
List[str]
|
Absolute paths to the downloaded feeds (ZIP files, or |
List[str]
|
extracted folders if |