API

pdf12step.cli

pdf12step.cli.do_download(ctx)[source]
pdf12step.cli.ensure_config(ctx)[source]
pdf12step.cli.prompt(name, title, default=None, cast=<class 'str'>)[source]

Prompts user input and returns a variable with type cast

pdf12step.client

class pdf12step.client.Client(site_url, api_url, nonce_url=None, api_key=None)[source]

Bases: object

Client that makes HTTP[S] calls to the WP site and fetches the data

Parameters

url (str) – Base URL of the WP site to gather data from

api_url = None
download(sections=None, format='json', data_dir='/home/docs/checkouts/readthedocs.org/user_builds/pdf12step/checkouts/latest/docs/data', prefix=None)[source]

Downloads all the TSML endpoints meeting data to the DATA_DIR destination.

Parameters
  • sections (tuple) – Specific sections to download (eg meetings)

  • format (str) – Which format to load the data in (eg json/csv)

get(*args, **kwargs)[source]

Returns a GET request to the given resource

groups()[source]

Loads groups TSML endpoint data

Return type

list

locations()[source]

Loads locations TSML endpoint data

Return type

list

meetings(**params)[source]

Returns meeting data with the given query params

Parameters

params (dict) – Query parameters to use in GET request

Return type

list

property nonce

Fetches the nonce on a base page to use in subsequent requests to the WP site Bypasses WP CSRF protection

Return type

str

nonce_url = None
post(*args, **kwargs)[source]

Returns a POST request to the given resource

regions()[source]

Loads regions TSML endpoint data

Return type

list

sections = ('meetings',)
tsml(entity, params=None)[source]

Returns and loads the data from the named entity TSML endpoint

Parameters

entity (str) – Name of the entity to load (eg meetings/locations)

Return type

list

pdf12step.config

class pdf12step.config.Config(arg=(), **kwargs)[source]

Bases: pdf12step.adict.AttrDict

Config instance that is passed to the template context as config Defines sane defaults and loads config values from YAML config file

classmethod load(args)[source]

Loads the config from defaults, file and args in that order

Parameters

args (dict) – Args override pass for runtime overrides

pdf12step.flask_app

pdf12step.meetings

class pdf12step.meetings.Meeting(arg=(), **kwargs)[source]

Bases: pdf12step.adict.AttrDict

property address_display

Displays a long form address line

property attendance_option
property conference_id

Returns the conference ID from the URL usually used for zoom

property conference_id_formatted

Returns a formatted conference ID. Eg 000 000 0000 for zoom

property conference_notes_display

Gets the text of the conference notes

property conference_type

Returns the type of conference URL by domain name (zoom/gotomeet/google) Returns domain if nothing matches

property conference_url

Returns a cleaned conference_url

property day_display

Gets the weekday name (eg Thursday)

property id_display

Gets a unique ID of the meeting either from the id or slug field or python generated

property is_conference

Returns True if the attendance_option is either online or hybrid. Failing having that value, determines whether a conference_url is set

property latlon

Returns the latitude,longitude tuple for usage in map locations

property notes_list

Returns a list of notes

property region_display

Gets the text of the region and sub_region

property time_display

Returns the formatted time of day in H:M AM/PM

property zipcode

Returns a 5 digit zipcode from the formatted address

class pdf12step.meetings.MeetingSet(fn_or_obj)[source]

Bases: object

property by_id

Returns a dictionary mapping between the Meeting’s ID and the Meeting object itself

by_value(attr, sort=False, limit=None, cast=<class 'str'>, reverse=False)[source]

Groups the results by the given attribute values. Returns a dict with the values as keys and filtered MeetingSet as values If sorted, it returns a sorted items list If limited, only returns up to X number of Meetings

copy()[source]
filter(**kwargs)[source]

Filter by all passed attribute value key pairs (AND filter)

filter_types(types)[source]

Filter by passed list of types to ignore

property index

Returns sorted list of meeting index section information Used to show which meetings meet in which zipcode and on which days

property items
limit(num)[source]

Limits the MeetingSet to num entries

Parameters

num (int) – Limit number

Return type

MeetingSet

property names

Returns a value_set of names

property regions

Returns a sorted list of regions and the zipcodes associated with them

sort(*attrs, reverse=False)[source]

Returns a new MeetingSet isinstance with the items ordered by the given attributes

property types

Returns a value_set of types

value_count(attr)[source]

Returns a dict with the attribute’s values and the number of occurances

value_set(attr, sort=False, filter_none=False)[source]

Returns a set of unique values for the passed atribute name

Parameters

attr (str) – Attribute name of a Meeting

Return type

set

property zipcodes

Returns a set of all zipcodes for meetings in the MeetingSet

pdf12step.meetings.clean_url(url)[source]

Cleans and unquotes a URL that might be poorly formatted

Parameters

url (str) – URL string to clean/unquote

Return type

str

pdf12step.templating

class pdf12step.templating.Context(config, args)[source]

Bases: dict

Context for jinja2 templating

Parameters

args (dict) – Runtime arguments to inject into template context

property env

Returns jinja2 Environment used to render all templates.

Return type

jinja2.Environment

property filtered_codes

Returns a list of meeting (code, name) after the codes have been filtered and remapped

Return type

list

get_meetings(meetings_file=None)[source]

Loads list of meetings for main context based on filters/limiting

Return type

MeetingSet

html(template=None)[source]

Gets the weasyprint HTML instance from this ontext

Return type

weasyprint.HTML

pdf(template=None)[source]

Returns the PDF content from this of context

Return type

bytes

prerender()[source]

Prerenders the assets ahead of page render to ensure proper values in assets are set

property qrcode
render(template=None)[source]

Renders a template by name and returns its content

Parameters

template (str) – relative name of template to load

Return type

str

property stylesheets

Returns a list of CSS stylesheets to include. Adds default stylesheet assets/css/style.css first and adds others from config.stylesheets

Return type

list

property template_dirs

Returns a list of template directories for jinja2 to search Adds default stylesheet pdf12step/templates first and adds others from config.stylesheets

Return type

list

property zipcodes_by_region

Returns a mapping of region->zipcode for zipcode list in config

Return type

dict

pdf12step.templating.asset_join(asset_dir, *paths)[source]