pyroxy.controllers.simple

pyroxy.controllers.simple.asbool(val)[source]

Attempts to coerce val to a boolean value. This is largely based off of paste.deploy.converters.asbool() with a few stylistic tweaks added.

Raises :ValueError if the value could not be coerced to a True or False value.
Returns:True or False, depending on what val was coerced to.

Generates a list of links to remove based on which links are preferred.

Parameters:
  • external_download_links (list) – list of internal download links
  • home_pages (list) – list of home pages
  • internal_download_links (list) – list of internal download links
  • unknown_links (list) – list of unknown links, or links that do not match either any of the previous three.
Returns:

list of lxml.etree.ElementTree.Element that are safe to be removed.

pyroxy.controllers.simple.filter_index(index_path)[source]

Path to an index page (index.html, typically). This function will parse the results into an lxml tree, call remove_links() on the resulting tree, and then convert it back to an HTML page.

Parameters:index_path – Absolute path to the index file. This MUST already be created, and must be a file.
Raises :If the file could not be opened, a 404 exception will be raised.
Returns:An lxml formatted HTML page as a string, containing the final, filtered version of the page.
pyroxy.controllers.simple.package_list(package_name)[source]

Controller used to serve up a package listing.

Parameters:package_name (string) – Name of the Python package to retrieve and filter the simple page for. Capitalization matters, depending on your operating system–i.e., on Linux, pylons != Pylons.
Returns:The raw simple page if the package was whitelisted, or a filtered page if it was not.

Predicate used to filter external download links. Currently, the only config value is allowed_extensions.

Parameters:
  • package_name (string) – Name of the Python package to retrieve and filter the simple page for.
  • href – Absolute URL pointing to a downloadable file on a third-party web site.
  • title – Text component of the link from the simple page. This can include suffixes such as download_url and home_page, which can be used as part of the filter.
Returns:

True if the external download link should be included in the output, False otherwise.

pyroxy.controllers.simple.pred_filter_home_pages(package_name, href, title)[source]

Predicate used to filter home pages.

Parameters:
  • package_name (string) – Name of the Python package to retrieve and filter the simple page for.
  • href – Absolute URL to a home page (i.e., a third party site)
  • title – Text component of the link from the simple page. This can include suffixes such as download_url and home_page, which can be used as part of the filter.
Returns:

True if the home page link should be included in the output, False otherwise.

Predicate used to filter internal download links. Currently, the only config value is allowed_extensions.

Parameters:
  • package_name (string) – Name of the Python package to retrieve and filter the simple page for.
  • href – Relative URL generated from the simple page (i.e., ../../packages/a/b/c/pyroxy-0.1.tar.gz)
  • title – Text component of the link from the simple page. This can include suffixes such as download_url and home_page, which can be used as part of the filter.
Returns:

True if the internal download link should be included in the output, False otherwise.

Filters out links based on the various predicates. Unfortunately, right now, the predicates aren’t configurable.

Parameters:
  • package_name (string) – Name of the Python package to retrieve and filter the simple page for.
  • html_treelxml.tree representing the simple page.
Returns:

A modified lxml.tree with specific links filtered out.

Parses through a list of elements, and splits them up based on their type.

Parameters:
  • package_name (string) – Name of the Python package to retrieve and filter the simple page for.
  • elements (iterable) – iterable containing lxml.etree.ElementTree.Element
Returns:

Tuple of lists, (external_download_links, home_pages, internal_download_links, unknown_links).

Project Versions

Previous topic

pyroxy.config

Next topic

pyroxy.controllers.static

This Page