complexity Package

complexity Package


Main package for Complexity.

conf Module


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


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


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


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


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


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


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


Helper functions used throughout Complexity.


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.

  • 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

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.