granicus_archiver.web.filters¶
- class granicus_archiver.web.filters.Context[source]¶
Bases:
TypedDictFilter context
- app: Application¶
The current application
- request: Request¶
The current request
- granicus_archiver.web.filters.local_tz(ctx: Context, dt: datetime) datetime[source]¶
Convert a datetime to the app’s local timezone (stored in
types.TimezoneKey)
- granicus_archiver.web.filters.datetime_format(ctx: Context, dt: datetime, fmt: str = '%m/%d/%Y %H:%M') str[source]¶
Format a datetime object using
datetime.datetime.strftime()The timezone of the datetime object will first be converted using
local_tz().
- granicus_archiver.web.filters.date_format(ctx: Context, dt: datetime | date, fmt: str = '%x') str[source]¶
Format a date or datetime object as a date using
datetime.datetime.strftime()The timezone of the datetime object will first be converted using
local_tz().
- granicus_archiver.web.filters.time_format(ctx: Context, dt: datetime, fmt: str = '%X') str[source]¶
Format a datetime object as a time using
datetime.datetime.strftime()The timezone of the datetime object will first be converted using
local_tz().
- granicus_archiver.web.filters.duration_format(td: timedelta | float) str[source]¶
Format a timedelta or number of seconds as
HH:MM:SS
- granicus_archiver.web.filters.snake_case_to_title(s: str) str[source]¶
Convert a snake_case string to title case
- granicus_archiver.web.filters.url_query(ctx: Context, query_: dict[str, str] | None = None, merge: bool = True) URL[source]¶
Add query parameters to the current request URL
- granicus_archiver.web.filters.static_path(ctx: Context, static_name: Literal['assets', 'granicus', 'legistar', 'legistar_rguid'], filename: Path | str) URL[source]¶
Get a URL for a static file
- Parameters:
static_name (Literal['assets', 'granicus', 'legistar', 'legistar_rguid']) – The name of the static root to use (a member of
types.StaticUrlRoots).filename (Path | str) – The path to the file, relative to the static root
ctx (Context)
- Return type:
- granicus_archiver.web.filters.clip_url(ctx: Context, clip_id: CLIP_ID, file_type: Literal['video', 'audio', 'chapters']) URL[source]¶
Get the s3 URL for a clip file
Note
For the
chaptersfile type, the URL will be for a local view of the chapters file (views.clip_webvtt()). This is to prevent issues with CORS.