granicus_archiver.config¶
- granicus_archiver.config.get_app_config(*parts: Path | str) Path[source]¶
Get the user config directory for the app
Any arguments (if provided) will be joined to the path
- Parameters:
parts (Path | str)
- Return type:
Path
- granicus_archiver.config.get_app_cache(*parts: Path | str) Path[source]¶
Get the user cache directory for the app
Any arguments (if provided) will be joined to the path
- Parameters:
parts (Path | str)
- Return type:
Path
- class granicus_archiver.config.BaseConfig[source]¶
Bases:
Serializable- group_key: ClassVar[Literal['root', 'google', 'aws', 'legistar']]¶
Unique key for
BaseConfigsubclasses
- classmethod iter_child_config_classes() Iterator[tuple[str, type[BaseConfig]]][source]¶
Iterate over child config classes
- Return type:
Iterator[tuple[str, type[BaseConfig]]]
- property child_configs: dict[str, BaseConfig]¶
Mapping of child config instances by their attribute name
- abstract classmethod build_defaults(**kwargs) Self[source]¶
Create the config using defaults
Any provided keyword arguments will override the default
- Return type:
- class granicus_archiver.config.GoogleConfig(user_credentials_filename: Path, drive_folder: Path, legistar_drive_folder: Path, rguid_legistar_drive_folder: Path, folder_cache_file: Path, meta_cache_file: Path)[source]¶
Bases:
BaseConfigGoogle config
- Parameters:
user_credentials_filename (Path)
drive_folder (Path)
legistar_drive_folder (Path)
rguid_legistar_drive_folder (Path)
folder_cache_file (Path)
meta_cache_file (Path)
- user_credentials_filename: Path¶
Path to store OAuth credentials
- drive_folder: Path¶
Root folder name to upload within Drive
- legistar_drive_folder: Path¶
Root folder name to upload legistar items within Drive
- rguid_legistar_drive_folder: Path¶
Root folder name to upload rguid legistar items within Drive
- folder_cache_file: Path¶
Path to store folder cache
- meta_cache_file: Path¶
Path to store metadata cache
- group_key: ClassVar[Literal['root', 'google', 'aws', 'legistar']] = 'google'¶
Unique key for
BaseConfigsubclasses
- class granicus_archiver.config.AWSConfig(bucket_name: str, clips_prefix: Path, legistar_prefix: Path, legistar_rguid_prefix: Path, region_name: str | None = None, s3_endpoint_url: URL | None = None, credentials_profile: str = 'default', access_key_id: str | None = None, secret_access_key: str | None = None, object_url_format: str = 'https://s3.amazonaws.com/{bucket_name}/{key}')[source]¶
Bases:
BaseConfigAWS Config
- Parameters:
- default_object_url_fmt: ClassVar[str] = 'https://s3.amazonaws.com/{bucket_name}/{key}'¶
Default
object_url_format
- clips_prefix: Path¶
Prefix for clips
- legistar_prefix: Path¶
Prefix for legistar items
- legistar_rguid_prefix: Path¶
Prefix for rguid legistar items
- s3_endpoint_url: URL | None = None¶
AWS S3 endpoint URL. If not set, the default endpoint will be used
- access_key_id: str | None = None¶
AWS Access Key ID. If not set, the default credentials provider chain will be used
- secret_access_key: str | None = None¶
AWS Secret Access Key. If not set, the default credentials provider chain will be used
- object_url_format: str = 'https://s3.amazonaws.com/{bucket_name}/{key}'¶
Format string for generating object URLs.
Required fields are
key(the S3 object key name)
- group_key: ClassVar[Literal['root', 'google', 'aws', 'legistar']] = 'aws'¶
Unique key for
BaseConfigsubclasses
- get_object_url(key: Key, scheme: str | None = None) URL[source]¶
Get a URL for an S3 key within
bucket_name- Parameters:
key (Key)
scheme (str | None)
- Return type:
URL
- class granicus_archiver.config.LegistarConfig(out_dir: ~pathlib._local.Path, out_dir_abs: ~pathlib._local.Path, data_file: ~pathlib._local.Path, search_index_dir: ~pathlib._local.Path, feed_urls: dict[str, ~yarl.URL] = <factory>, feed_overflows_allowed: list[str] = <factory>, category_maps: dict[str, str] = <factory>)[source]¶
Bases:
BaseConfigLegistar Config
- Parameters:
- out_dir: Path¶
Root directory to store downloaded files (relatve to the current working directory). Defaults to
data/legistar
- out_dir_abs: Path¶
Root directory to store downloaded files (absolute path)
- data_file: Path¶
Filename to store parsed data. Defaults to “<out-dir>/data.json”
- search_index_dir: Path¶
Directory to store the search index (relative to the current working directory)
- feed_overflows_allowed: list[str]¶
A list of feed names (keys of
feed_urls) that are allowed to reach the 100 item limit described inlegistar.rss_parser.Feed.from_feed()
- category_maps: dict[str, str]¶
A
dictof any custom mappings to match theClip.locationfields to their appropriatelegistar.rss_parser.FeedItem.categoryThe keys for this should be the
locationwith the values set to thecategory.
- group_key: ClassVar[Literal['root', 'google', 'aws', 'legistar']] = 'legistar'¶
Unique key for
BaseConfigsubclasses
- is_feed_overflow_allowed(feed: str | URL) bool[source]¶
Check whether the given feed name or url is allowed to overflow
If a string is supplied this returns whether it is present in
feed_overflows_allowed.If a
URLis supplied,feed_urlswill be searched and the matching key (if any) will be checked.
- class granicus_archiver.config.Config(out_dir: 'Path', out_dir_abs: 'Path', data_file: 'Path', timestamp_file: 'Path', granicus_data_url: 'URL | None', legistar: 'LegistarConfig', google: 'GoogleConfig', aws: 'AWSConfig', local_timezone_name: 'str | None')[source]¶
Bases:
BaseConfig- Parameters:
out_dir (Path)
out_dir_abs (Path)
data_file (Path)
timestamp_file (Path)
granicus_data_url (URL | None)
legistar (LegistarConfig)
google (GoogleConfig)
aws (AWSConfig)
local_timezone_name (str | None)
- out_dir: Path¶
Root directory to store downloaded files (relatve to the current working directory)
- out_dir_abs: Path¶
Root directory to store downloaded files (absolute path)
- data_file: Path¶
Filename to store download information. Defaults to “<out-dir>/data.json”
- timestamp_file: Path¶
Filename to store clip timestamp information. Defaults to “<out-dir>/timestamp-data.yaml”
- legistar: LegistarConfig¶
LegistarConfiginstance
- google: GoogleConfig¶
GoogleConfiginstance
- group_key: ClassVar[Literal['root', 'google', 'aws', 'legistar']] = 'root'¶
Unique key for
BaseConfigsubclasses
- classmethod get_app_config(*parts: Path | str) Path[source]¶
Get the user config directory for the app
Any arguments (if provided) will be joined to the path
- Parameters:
parts (Path | str)
- Return type:
Path
- classmethod get_app_cache(*parts: Path | str) Path[source]¶
Get the user cache directory for the app
Any arguments (if provided) will be joined to the path
- Parameters:
parts (Path | str)
- Return type:
Path
- get_group(key: Literal['root', 'google', 'aws', 'legistar']) BaseConfig[source]¶
Get a
BaseConfiginstance by itsgroup_key- Parameters:
key (Literal['root', 'google', 'aws', 'legistar'])
- Return type:
- save(filename: PathLike) None[source]¶
Save the config to the given filename
- Parameters:
filename (PathLike)
- Return type:
None