zazu package¶
Submodules¶
zazu.build module¶
Build command for zazu.
-
class
zazu.build.BuildGoal(goal)¶ Bases:
objectStore a configuration for a single build goal with one or more architectures.
-
builds()¶ Get dictionary of builds.
-
description()¶ Get string description.
-
get_build(arch)¶ Get a build by arch.
-
goal()¶ Get string build goal.
-
name()¶ Get string name.
-
-
class
zazu.build.BuildSpec(goal, type='minSizeRel', vars={}, requires={}, description='', arch='', script=None, artifacts=[])¶ Bases:
objectA build specification that may have multiple target architectures.
-
build_arch()¶ Return the build architecture string.
-
build_artifacts()¶ Return the list of build artifacts.
-
build_description()¶ Return the build description string.
-
build_goal()¶ Return the build goal string.
-
build_script()¶ Return the list of build script steps.
-
build_type()¶ Return the build type string.
-
build_vars()¶ Return the dictionary of build variables.
-
-
class
zazu.build.ComponentConfiguration(component)¶ Bases:
objectStore a configuration for a single component.
-
description()¶ Get string description.
-
get_spec(goal, arch, type)¶ Get a BuildSpec object for the given params.
-
goals()¶ Get list of goals.
-
name()¶ Get string name.
-
-
zazu.build.add_version_args(repo_root, build_num, args)¶ Add version strings and build number arguments to args.
-
zazu.build.cmake_build(repo_root, arch, type, goal, verbose, vars)¶ Build using cmake.
-
zazu.build.make_semver(repo_root, build_number)¶ Parse SCM info and creates a semantic version.
-
zazu.build.make_version_number(branch_name, build_number, tag, sha)¶ Convert repo metadata and build version into a semantic version.
-
zazu.build.parse_describe(repo_root)¶ Parse the results of git describe into branch name, sha, and tags.
-
zazu.build.parse_key_value_pairs(arg_string)¶ Parse a argument string in the form x=y j=k and returns a dictionary of the key value pairs.
-
zazu.build.pep440_from_semver(semver)¶ Convert semantic version to PEP440 compliant version.
-
zazu.build.sanitize_branch_name(branch_name)¶ Replace punctuation that cannot be in semantic version from a branch name with dashes.
-
zazu.build.script_build(repo_root, spec, build_args, verbose)¶ Build using a provided shell script.
-
zazu.build.tag_to_version(tag)¶ Convert a git tag into a semantic version string.
i.e. R4.1 becomes 4.1.0. A leading ‘r’ or ‘v’ is optional on the tag.
zazu.build_server module¶
Build server related classes.
-
class
zazu.build_server.BuildServer¶ Bases:
objectParent of all BuildServer objects.
zazu.cli module¶
Entry point for zazu.
-
zazu.cli.init()¶ Run on startup to allow zazu to be run as a module.
zazu.cmake_helper module¶
Defines helper functions for cmake interaction.
-
zazu.cmake_helper.architecture_to_generator(arch)¶ Get the required generator for a given architecture.
-
zazu.cmake_helper.build(build_dir, arch, build_type, target, verbose)¶ Build using CMake.
-
zazu.cmake_helper.configure(repo_root, build_dir, arch, build_type, build_variables, echo=<function <lambda>>)¶ Configure a cmake based project to be built and caches args used to bypass configuration in future.
-
zazu.cmake_helper.known_arches()¶ List arches that zazu is familiar with.
zazu.code_reviewer module¶
Code reviewer related classes.
-
class
zazu.code_reviewer.CodeReview¶ Bases:
objectProvides an interface for code reviews.
-
assignee¶ Return the assignee of the code review.
-
base¶ Return the branch name that is being merged to.
-
browse_url¶ Get the url to open to display the code review.
-
description¶ Return the string status of the code review.
-
head¶ Return the branch name that is being merged from.
-
id¶ Return the unique id of the code review.
-
merged¶ Return True if the code review is closed.
-
name¶ Return the string name of the code review.
-
status¶ Return the string status of the code review.
-
-
class
zazu.code_reviewer.CodeReviewer¶ Bases:
objectParent of all CodeReviewer objects.
-
connect()¶ Get handle to ensure that credentials are in place.
-
create_review(title, base, head, body)¶ Create a new review.
-
review(status, head, base)¶ Get list of reviews matching the supplied filters.
-
-
exception
zazu.code_reviewer.CodeReviewerError¶ Bases:
exceptions.ExceptionParent of all CodeReview errors.
zazu.config module¶
Config classes and methods for zazu.
-
class
zazu.config.Config(repo_root)¶ Bases:
objectHold all zazu configuration info.
-
build_server()¶ Lazily create a build server object.
-
check_repo()¶ Check that the config has a valid repo set.
-
ci_config()¶ Return the CI configuration if one exists.
-
code_reviewer()¶ Lazily create and return code reviewr object.
-
code_reviewer_config()¶ Return the code reviewer configuration if one exists.
Raises: click.ClickException– if no code review configuration is present.
-
issue_tracker()¶ Lazily create a IssueTracker object.
-
issue_tracker_config()¶ Return the issue tracker configuration if one exists.
Raises: click.ClickException– if no issue tracker configuration is present.
-
project_config()¶ Parse and return the zazu yaml configuration file.
-
stylers()¶ Lazily create Styler objects from the style config.
-
zazu_version_required()¶ Return the version of zazu requested by the config file.
-
-
class
zazu.config.PluginFactory(name, subclass)¶ Bases:
objectA genetic plugin factory that uses the type field of the config to create the appropriate class.
-
from_config(config)¶ Make and initialize a plugin object from a config.
-
-
zazu.config.get_line(file_path, line_number)¶ Return line number in file.
-
zazu.config.load_yaml_file(search_paths, file_names)¶ Load a project yaml file.
-
zazu.config.make_col_indicator(index)¶ Return a carrot indicator at index.
-
zazu.config.path_gen(search_paths, file_names)¶ Generate full paths given a list of directories and list of file names.
-
zazu.config.styler_factory(config)¶ Make and initialize the Stylers from the config.
zazu.credential_helper module¶
Credential functions for zazu.
-
zazu.credential_helper.get_user_pass_credentials(component, use_saved=True)¶ Retrieve a stored user/password for a named component or offers to store a new set.
zazu.git_helper module¶
Git functions for zazu.
-
zazu.git_helper.check_git_hook(hooks_folder, hook_name, hook_resource_path)¶ Check that a git hook is in place.
-
zazu.git_helper.check_git_hooks(repo_base)¶ Check that all known git hooks are in place.
-
zazu.git_helper.filter_undeletable(branches)¶ Filter out branches that we don’t want to delete.
-
zazu.git_helper.get_default_git_hooks()¶ Get list of known git hooks to install.
-
zazu.git_helper.get_hooks_path(repo_base)¶ Get the path for git hooks.
-
zazu.git_helper.get_merged_branches(repo, target_branch, remote=False)¶ Return list of branches that have been merged with the target_branch.
-
zazu.git_helper.get_repo_root(starting_dir)¶ Get the root directory of the git repo.
-
zazu.git_helper.get_touched_files(repo)¶ Get list of files that are scheduled to be committed (Added, created, modified, or renamed).
-
zazu.git_helper.install_git_hook(hooks_folder, hook_name, hook_resource_path)¶ Enforce that a git hook is in place.
-
zazu.git_helper.install_git_hooks(repo_base)¶ Enforce that all known git hooks are in place.
-
zazu.git_helper.parse_branch_return_list(branches)¶ Parse return from git branch into list of branch names.
-
zazu.git_helper.read_staged(path)¶ Read the contents of the staged version of the file.
zazu.github_helper module¶
Github functions for zazu.
-
zazu.github_helper.make_gh()¶ Make github object with token from the keychain.
-
zazu.github_helper.make_gh_token()¶ Make new GitHub token.
-
zazu.github_helper.parse_github_url(url)¶ Parse github url into organization and repo name.
zazu.issue_tracker module¶
Issue tracker related classes.
-
class
zazu.issue_tracker.Issue¶ Bases:
objectParent of all Issues.
-
assignee¶ Get the string assignee of the issue.
-
browse_url¶ Get the url to open to display the issue.
-
closed¶ Return True if the issue is closed.
-
description¶ Get the description of the issue.
-
id¶ Get the string id of the issue.
-
name¶ Get the name of the issue.
-
status¶ Get the status string of the issue.
-
type¶ Get the string type of the issue.
-
-
class
zazu.issue_tracker.IssueTracker¶ Bases:
objectParent of all IssueTracker objects.
-
exception
zazu.issue_tracker.IssueTrackerError¶ Bases:
exceptions.ExceptionParent of all IssueTracker errors.
zazu.style module¶
Style functions for zazu.
-
zazu.style.read_file(path)¶ Read a file and return its contents as a string.
-
zazu.style.stage_patch(path, input_string, styled_string)¶ Create a patch between input_string and output_string and add the patch to the git staging area.
Parameters: - path – the path of the file being patched.
- input_string – the current state of the file in the git stage.
- styled_string – the properly styled string to stage.
-
zazu.style.style_file(styler, path, read_fn, write_fn)¶ Style a file.
Parameters: - styler – the styler to use to style the file.
- path – the file path.
- read_fn – function used to read in the file contents.
- write_fn – function used to write out the styled file, or None
-
zazu.style.write_file(path, _, styled_string)¶ Write styled_string string to a file.
zazu.styler module¶
Styler class for zazu.
-
class
zazu.styler.Styler(options=[], excludes=[], includes=[])¶ Bases:
objectParent of all style plugins.
-
classmethod
from_config(config, excludes, includes)¶ Create a Styler based on a configuration dictionary.
Parameters: - config – the configuration dictionary.
- excludes – patterns to exclude.
- includes – patterns to include.
Returns: Styler with config options set.
-
style_string(string)¶ Style a string and return a diff of requested changes.
Parameters: string – the string to style Returns: A unified diff of requested changes or an empty string if no changes are requested. Raises: NotImplementedError
-
classmethod
zazu.upgrade module¶
Update command for zazu.
zazu.util module¶
Utility functions for zazu.
-
zazu.util.call(*args, **kwargs)¶ Like subprocess.call but raise an exception if the program cannot be found.
-
zazu.util.cd(*args, **kwds)¶ Change directory context manager.
Parameters: path – the path to change to.
-
zazu.util.check_output(*args, **kwargs)¶ Like subprocess.check_output but raises an exception if the program cannot be found.
-
zazu.util.check_popen(args, stdin_str='', *other_args, **kwargs)¶ Like subprocess.Popen but raises an exception if the program cannot be found.
Parameters: - args – passed to Popen.
- stdinput_str – a string that will be sent to std input via communicate().
- other_args – other arguments passed to Popen.
- kwargs – other kwargs passed to Popen.
Raises: CalledProcessError– on non zero return from the child process.click.ClickException– if the program can’t be found.
-
zazu.util.dispatch(work)¶ Dispatch a list of callables in multiple threads and yields their returns.
Parameters: work – the list of callables to execute. Yields: the results of the callables as they are finished.
-
zazu.util.format_checklist_item(tag, text, tag_formats=['\x1b[31m\x1b[1mFAIL\x1b[0m', '\x1b[32m\x1b[1m OK \x1b[0m'])¶ Format a list item based on an enumerated set of tags.
Parameters: - tag (int) – index into the tag_formats list.
- text (str) – the checklist text to display.
- tag_formats (list of str) – the possible states of the checklist.
- Returns (str):
- the checklist string.
-
zazu.util.lazy_import(scope, imports)¶ Declare a list of modules to import on their first use.
Parameters: - scope – the scope to import the modules into.
- imports – the list of modules to import.
-
zazu.util.pick(choices, message)¶ Interactively allow user to pick among a set of choices.
Parameters: - choices – list of possible choices.
- message – the message to display to the user.
-
zazu.util.pprint_list(data)¶ Format list as a bulleted list string.
Parameters: data (list) – the list to pprint. Returns: a newline separated pretty printed list. Return type: str
-
zazu.util.prompt(text, default=None, expected_type=<type 'str'>)¶ Prompt user for an input.
Parameters: - text (str) – the text to display to the user.
- default (str) – the default to return if the user doesn’t provide input.
- expected_type (type) – the type to cast the user’s return to.
Returns: user’s input casted to expected_type or default if no inout is provided.
-
zazu.util.raise_uninstalled(pkg_name)¶ Raise an exception for a missing package.
Parameters: pkg_name (str) – the package name that is missing. Raises: click.ClickException
-
zazu.util.scantree(base_path, include_patterns, exclude_patterns, exclude_hidden=False)¶ List files recursively that match any of the include glob patterns but are not in an excluded pattern.
Parameters: - base_path (str) – the path to scan.
- include_patterns (str) – list of glob patterns to include.
- exclude_patterns (str) – list of glob patterns to exclude.
- exclude_hidden (bool) – don’t include hidden files if True.
Returns: of file paths (relative to the base path) that match the input parameters.
Return type: list of str