API#
Typically use for urlfwd is through the Gh actions or CLI
This API is also useful for extending the CLI. Many of these functions offer flexible processing of basic information that could be used to create additional CLI functionality beyond what is already implemented.
Generators#
- urlfwd.genpage.create_landing(config_in, base_path, full_dict=None, index=False)#
create a landing page at base_path/index.html
Parameters config_in : dictionary
configurations to overwrite defaults with
- base_pathstrign or path
where to write the index.html file
- full_dictdictionary
from links.yml for making index
- indexbool
creat index
- urlfwd.genpage.files_from_dict(pages_to_create, overwrite=True, base_path='docs', genQRs=False, qrTOC='gallery', logging=False, config_in=None)#
given a dictionary, create html files
- Parameters:
pages_to_create (dictionary) – keys are names of pages, values are urls to redirect to
overwrite (bool) – overwrite files that exist
base_path (path or string) – where to store generated site default(docs)
logging (bool) – verbose mode or not
config_in (dict) – configurations to overwrite default with
- urlfwd.genpage.qrs_from_dict(pages_to_create, overwrite=True, flyer_pages=True, flyer_template_input='default', base_path='docs', logging=False, config_in=None)#
given a dictionary, create qr codes to each url and a flyer page for each
- Parameters:
pages_to_create (dictionary) – keys are names of pages, values are urls to redirect to
overwrite (bool) – overwrite files that exist
flyer_pages (bool) – to create an html file for each QR or not
flyer_template_input (string) – name of a stock flyer template (default, detailed) or html to use as the tempalte
base_path (path or string) – where to store generated site default(docs)
logging (bool) – verbose mode or not
config_in (dict) – configurations to overwrite default with
Link Management#
- class urlfwd.manage_links.FlyerListing(*args, **kwargs)#
a dictionary that can be used to store links and their descriptions names keys, value a dictionary with keys ‘url’ and ‘description’
- class urlfwd.manage_links.LinkListing(*args, **kwargs)#
a dictionary that can be used to store links by short name names as keys, urls as values
- urlfwd.manage_links.add_link(new_url, new_name, yaml_file, force=False, return_dict=False)#
add a new key to the yaml file
Parameters:#
- new_urlstring
URL to forward to, value in yaml file
- new_name: string
short url to create, key in yaml file
- yaml_filestring or file buffer
file to add to
- force: boolean
if true change a value for an existing key
- urlfwd.manage_links.find_duplicate_keys(source_yaml)#
find any duplicated keys in the source yaml
- Parameters:
source_yaml (string or file buffer) – file to parse
- Returns:
duplicates – list of repeated keys; empty if none
- Return type:
list
- urlfwd.manage_links.parse_yml(source_yaml, target_type='basic')#
determine yaml formalt type and return a usable object
- Parameters:
source_yaml (string or file buffer) – file to parse
target_type (string) – ‘basic’ for simple key: value pairs, ‘informational’ for key: {url: url, description: ‘description’} if not specified, will return the type basic
- Returns:
duplicates – list of repeated keys; empty if none
- Return type:
list