complexity Package

complexity Package

complexity

Main package for Complexity.

conf Module

complexity.conf

Functions for reading a complexity.yml configuration file and doing various configuration-related things.

complexity.conf.get_unexpanded_list(conf_dict)[source]

Given a configuration dict, returns the list of templates that were specified as unexpanded.

complexity.conf.read_conf(directory)[source]

Reads and parses the complexity.yml configuration file from a directory, if one is present. :param directory: Directory to look for a complexity.yml file. :returns: A conf dict, or False if no complexity.yml is present.

exceptions Module

complexity.exceptions

All exceptions used in the Complexity code base are defined here.

exception complexity.exceptions.ComplexityException[source]

Bases: Exception

Base exception class. All Complexity-specific exceptions subclass ComplexityException.

exception complexity.exceptions.MissingTemplateDirException[source]

Bases: complexity.exceptions.ComplexityException

Raised when a project is missing a templates/ subdirectory.

exception complexity.exceptions.NonHTMLFileException[source]

Bases: complexity.exceptions.ComplexityException

Raised when a project’s templates/ directory contains a non-HTML file.

exception complexity.exceptions.OutputDirExistsException[source]

Bases: complexity.exceptions.ComplexityException

Raised when a project’s output_dir exists and no_input=True.

generate Module

main Module

prep Module

complexity.prep

Functions for preparing a Complexity project for static site generation, before it actually happens.

complexity.prep.prompt_and_delete_cruft(output_dir)[source]

Asks if it’s okay to delete output_dir/. If so, go ahead and delete it.

Parameters:output_dir (directory) – The Complexity output directory, e.g. www/.

serve Module

complexity.serve

Functions for serving a static HTML website locally.

complexity.serve.serve_static_site(output_dir, port=9090)[source]

Serve a directory containing static HTML files, on a specified port.

Parameters:output_dir – Output directory to be served.

utils Module

complexity.utils

Helper functions used throughout Complexity.

complexity.utils.make_sure_path_exists(path)[source]

Ensures that a directory exists.

Parameters:path – A directory path.
complexity.utils.query_yes_no(question, default='yes')[source]

Ask a yes/no question via raw_input() and return their answer.

Parameters:
  • question – A string that is presented to the user.
  • default – The presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).

The “answer” return value is one of “yes” or “no”.

Adapted from http://stackoverflow.com/questions/3041986/python-command-line-yes-no-input http://code.activestate.com/recipes/577058/

complexity.utils.unicode_open(filename, *args, **kwargs)[source]

Opens a file as usual on Python 3, and with UTF-8 encoding on Python 2.

Parameters:filename – Name of file to open.