uw.local.wcms.bin package

Submodules

uw.local.wcms.bin.filter module

Filter to impose WCMS template on HTML pages.

Main program for the WCMS HTML filter.

class uw.local.wcms.bin.filter.Entry(arcname, hidden, external, label)

Bases: tuple

property arcname

Alias for field number 0

property external

Alias for field number 2

property hidden

Alias for field number 1

property label

Alias for field number 3

uw.local.wcms.bin.filter.apply_menu(template, document_root, request_path, sitelink, sitetitle)[source]
uw.local.wcms.bin.filter.apply_page(template, page, document_root, request_uri)[source]

Fill in the template with content from the document page.

Parameters
  • template – Beautiful Soup parsed template.

  • page – Beautiful Soup parsed document.

  • document_root – Python pathlib Path object for document root.

  • request_path – Array of URL path components for this request.

uw.local.wcms.bin.filter.apply_template(template, page)[source]
uw.local.wcms.bin.filter.main()[source]
uw.local.wcms.bin.filter.parse_entry(entry)[source]
uw.local.wcms.bin.filter.parse_htmenu(lines)[source]
uw.local.wcms.bin.filter.path_to_arcs(path)[source]
uw.local.wcms.bin.filter.show_menu(soup, root, arcs, sitelink, sitetitle)[source]
uw.local.wcms.bin.filter.show_submenu(soup, url_root, dir_root, arcs, sitelink=None, sitetitle=None)[source]

uw.local.wcms.bin.make_font_css module

Program to process downloaded font CSS from WCMS.

Main program for processing downloaded font CSS from WCMS. Scans each downloaded site for CSS @font-face directives and assembles a directory of font files and a CSS file to refer to the font files, overriding the font files specified by the original CSS files.

uw.local.wcms.bin.make_font_css.find_fonts(src, site)[source]

Find all font references in CSS for the specified site.

Parameters
  • src (str) – The base directory of downloaded site files.

  • site (str) – The directory to scan within the base directory.

Returns

A 2-tuple consisting of a dictionary from filenames to contents; and a list of warning/error messages applicable to this site.

Find all .css files within the site and scan them for @font-face sections. Collect the referenced font files together, along with a file of modified @font-face sections to refer to the collected font files.

uw.local.wcms.bin.make_font_css.main()[source]
uw.local.wcms.bin.make_font_css.re_capt(capture, contents)[source]

Construct a regular expression to capture the specified contents.

Parameters
  • capture (str) – The name to use when capturing the matched value.

  • contents (str) – The re text to match.

Returns

A regular expression in the form (?P[capture]<[contents]>) where [capture] is replaced by the capture name and [contents] is replaced by the contents regular expression.

uw.local.wcms.bin.make_font_css.writefiles(outputdir, files)[source]

Write the specified file contents to the specified directory.

Parameters
  • outputdir (str) – The name of the output directory.

  • files (dict) – A dictionary from filenames to file contents.

Create the specified directory if necessary and write the file contents to that directory.

uw.local.wcms.bin.templates module

Program to pre-process templates from WCMS.

uw.local.wcms.bin.templates.fix_template(template, template_dir)[source]

Make required adjustments and corrections to the template

uw.local.wcms.bin.templates.fix_url(url)[source]

Adjust the given URL to be absolute if necessary.

Parameters

url – The URL to adjust.

Returns

The adjusted URL.

A fragment-only URL is left unchanged; anything else is resolved relative to the root of the main UW site so the links end up going the same place they did in the original page.

uw.local.wcms.bin.templates.main()[source]
uw.local.wcms.bin.templates.process_template(template_dir, download_dir, output_dir)[source]

Process a single template.

Parameters
  • template_dir – The directory with information specifying the details of the template to process. Must contain a file specifying the source URL of the template.

  • download_dir – The base directory for the template download. Must contain the template file downloaded by the download process.

  • output_dir – The directory for the processed template.

Reads the source URL and uses it to find the input template. Processes the template document and writes the output to a corresponding filename in the output directory.

uw.local.wcms.bin.templates.process_templates(datadir, download_dir, output_dir)[source]

Process all templates.

Parameters
  • datadir – The base directory containing a directory for each template with information specifying the details of the template.

  • download_dir – The base directory for the template download.

  • output_dir – The directory for the processed templates.

uw.local.wcms.bin.templates.re_capt(**keys)[source]

Construct a regular expression to capture the specified contents.

Parameters

keys (dict) – A dictionary from capture group names to corresponding text regular expressions.

Returns

A dictionary from capture group names to corresponding regular expressions in the form (?P[capture]<[contents]>) where [capture] is replaced by the capture name and [contents] is replaced by the contents regular expression.

Module contents

Command implementations for WCMS project.

Modules implementing actions within the WCMS that need to be available as executable programs.