include package

Submodules

include.add module

include.add.add(projecthome, message)[source]

Add or update a blci repo

Positional Arguments:

projecthome:
  • The root directory of where the blci project is.
include.add.create_base_CI_conf(bl_conf, Git)[source]

Given a user defined project blci configuration file and the CI configuration file in the root of blci, create a new a config that encodes the following: - User defined tests - Triggers for code and data dependencies for any code or data change that will occur from an update action

Positional Arguments:

bl_conf:
  • A BLCI configuration config object
  • Base CI configuration file defined by blci
Git:
  • Git repo object from Gitpython package
include.add.create_remote_repo(bl_conf)[source]

Uses user-defined configuration file to create a public github repo that is initialized using configurations supplied to the BLCI configuration file.

Positional Arguments:

bl_conf:
  • A BLCI configuration config object with a
    credentials entry that is a path for a file containing a string representing a Github OAuth2 token.

Returns:

A PyGithub Repository object.

include.add.handle_gitignore(projecthome, bl_conf)[source]

Build/update the .gitignore file and ensure that blci ignored files are not added to repo. Some files like the credentials file should never be tracked or added to the remote repo.

Positional Arguments:

bl_conf:
  • A BLCI configuration config object
credentials_fn:
  • An existing path to a file containing credentials
include.add.travis_track(bl_conf)[source]

Track a github repo using travis CI programmatically

Positional Arguments:

bl_conf:
  • A BLCI configuration config object

include.bl_exceptions module

exception include.bl_exceptions.FileNotFoundException(msg)[source]

Bases: exceptions.IOError

exception include.bl_exceptions.FormatException(msg)[source]

Bases: exceptions.Exception

exception include.bl_exceptions.ParameterException(msg)[source]

Bases: exceptions.Exception

exception include.bl_exceptions.ParsingException(msg)[source]

Bases: exceptions.Exception

exception include.bl_exceptions.UnknownFileException(msg)[source]

Bases: exceptions.Exception

exception include.bl_exceptions.UnsupportedFileException(_type)[source]

Bases: include.bl_exceptions.UnknownFileException

include.bl_exceptions.err(err)[source]

Color an error message red

Positional Arguments:

err:
  • The message to be displayed
Returns:
  • A red colored message
include.bl_exceptions.warn(msg)[source]

Print a warning message

Positional Arguments:

msg:
  • The message to be displayed

include.build module

include.build.trigger_build(conf, projecthome)[source]

Hack to trigger a build. TODO: Remove the push to repo

Positional Arguments:

conf:
  • A BLCI configuration config object
projecthome:
  • root directory of the project

include.clean module

include.clean.clean_base_ci_config(projecthome, verbose=False)[source]

Delete Travis-CI configuration file

Positional Arguments:

projecthome:
  • The path to the root of the project

Optional Arguments:

verbose:
  • Print messages when actions are taken
include.clean.clean_bl_config(projecthome, verbose=False)[source]

Delete BLCI configuration file

Positional Arguments:

projecthome:
  • The path to the root of the project

Optional Arguments:

verbose:
  • Print messages when actions are taken
include.clean.clean_dependencies(projecthome, verbose=False)[source]

Delete BLCI dependency metadata file

Positional Arguments:

projecthome:
  • The path to the root of the project
include.clean.clean_git(projecthome, verbose=False)[source]

Delete Git ignore file

Positional Arguments:

projecthome:
  • The path to the root of the project

Optional Arguments:

verbose:
  • Print messages when actions are taken
include.clean.cleanall(projecthome, verbose=False)[source]

Delete all BLCI configurations and metadata files

Positional Arguments:

projecthome:
  • The path to the root of the project

Optional Arguments:

verbose:
  • Print messages when actions are taken

include.common module

include.common.delete(path, verbose=False)[source]

Delete a file, or directory

Positional Arguments:

path:
  • The path to the file system object to be deleted

Optional Arguments:

verbose:
  • Print debug messages when actions are taken
include.common.get_ext(path)[source]

Given a path return the file extension.

Positional Arguments:

path: The file whose path we assess

include.common.is_git_branch(branchname, _dir='./')[source]

Does the the branch specified exist in the repo

Positional Arguments:

branchname:
  • The git branch you wish to evaluate existence of

Optional Arguments:

_dir:
  • The dir that is a git repo
include.common.is_git_repo(path)[source]

Rudimentary tests for if I have a git repo. Simply look for .git directory

Positional Arguments:

path:
  • The path that we are assessing
include.common.localize(base, path)[source]

Returns a localized path with respect to a base path. For instance if we have base=/home/floki/ and path=/home/floki/ragnar/foo.txt, localize will return ragnar/foo.txt

Positional Arguments:

base:
  • The base path from which we wish to localize a file path
path:
  • The path that we aim to localize
include.common.ls_r(path, fileext)[source]

Works like a shells ls -r syscall, but searches with a given file extensions (fileext) in mind

Positional Arguments:

path:
  • The base path from where we traverse the directory structure
fileext:
  • The file extensionS we care about when we traverse
include.common.read_token(credentials_fn)[source]

Read a github token from a file that has it stored as plain text

Positional Arguments:

credentials_fn:
  • An existing path to a file containing credentials
include.common.read_yml(fn)[source]

Read a YAML formatted file in a python dictionary

Positional Arguments:

fn:
  • The file path on disk
include.common.write_yml(yamldict, fn, verbose=False)[source]

Write a YAML formatted file to disk.

Positional Arguments:

yamldict:
  • The python dictionary object we will write as YAML
fn:
  • The file name we wish to use

Optional Arguments:

verbose:
  • Prints debug information if true

include.config module

class include.config.config(fn, projecthome, on_anomaly='IGNORE', add_defaults=True)[source]
add_data_loc_path(path)[source]

Add a path to the data_loc section of the blci config file.

Positional Arguments:

path:
  • The path to a data file that will be written by blci.
add_defaults()[source]

Add default values for any settings that we provide defaults for.

bashRE_2_pyRE(regex)[source]

TODO: Very rudimentary way to change bash shell regexs to python.

Positional Arguments:

regex:
  • The bash regular expression
build_data_dep_stub(overwrite=True)[source]

Build a stub of a config or add data dependencies to an existing config given one or more directories containing data.

Positional Arguments:

overwrite:
  • Overwrite the existing data dependency file, if it does exist.
get(setting)[source]

Get a setting.

Positional Arguments:

setting:
  • The name of setting you seek
Returns:
  • The value of the setting.
getall()[source]
has_setting(setting)[source]

Does the configuration file have the setting?

Positional Arguments:

setting:
  • The name of setting you seek.
Returns:
  • A bool indicating if the setting is set or not.
isignored(path)[source]

Determine if a provided path is meant to be ignored by blci.

Positional Arguments:

path:
  • The path or regex describing the path.
isvalid()[source]

Is the configuration file a valid one?

Returns:

A bool for validity of the configuration file based on the on_anomaly=IGNORE argument to __check_valid__()

read_config(fn, on_anomaly='ERROR')[source]

Given a configuration file that is in YAML format

Positional Arguments:

fn:
  • The config filename that you are reading or intend to write

Optional Arguments:

on_anomaly:
  • Action to perform when we encounter an anomaly
track_datafile(path)[source]

Add a path stub to the data_dep read and write sections.

Positional Arguments:

path:
  • The path to a data file that will be written by blci.
unique_fn(path)[source]

Generate a unique path given a proposed path. It simply adds a count to the proposed path until it is a non-existent path.

Positional Arguments:

path:
  • The proposed path to be written.

Retuns:

A str for the path of unique file.

write(overwrite=True)[source]

Write the config file to disk.

Optional Arguments:

overwrite:
  • Overwrite the existing config file if it does exist.

include.dependencies module

class include.dependencies.DependParser(fileext, projecthome)[source]

Bases: object

read(fn)[source]
Generic code reader to extract deps from a file. NOTE: The
file extension is very important as it determines A LOT!

** Positional Arguments **

fn:
  • The filename to be read
read_deps()[source]
readcode(code_loc)[source]

Given a list of files in any supported languge, parse through each one.

Positional Arguments:

code_loc:
  • The dir in which the code resides
write(outfn='')[source]

Write dependency struct to disk

** Positional Arguments **

outfn:
  • The path/name of dep fileext

include.init module

include.init.init(projecthome, overwrite=True)[source]

Initialize a blci project with the depenedency file and stubbed out blci configuration file

Positional Arguments:

projecthome:
  • The path to the root of the project

Optional Arguments:

overwrite:
  • Write over any old configuration file that may exist in projecthome.
    If False then the new configuration file will have the filename blci_\d+.yml.

include.settings module

Default file names we expect to exsit

include.settings.BL_DEFAULTS = {'ignore': ['.*', '.pyc', '.d', '.o', '.javac', '.rbin', '.mat', 'blci.yml.old'], 'code_loc': ['code'], 'version': '', 'description': 'A BrainLab Continuous Integration repo', 'credentials': '.credentials', 'data_loc': ['data'], 'path': [], 'data_dep': {'read': {}, 'write': {}}, 'nthread': 1, 'name': ''}

Optional arguments that can be left undefined

include.settings.BL_DEFAULT_CREDS = '.credentials'

These are all the settings/parameters blci supports

include.settings.BL_DEFAULT_LANG_VERSION = {'c': 'c11', 'java': 7, 'mat': 7, 'python': 2.7, 'julia': 0.4, 'r': 3, 'cpp': 'c++11'}

Language version defaults

include.settings.BL_DEFAULT_READ = {'c': ['.c', '.h'], 'java': ['.java'], 'mat': ['.m'], 'python': ['.py', '.pyx'], 'julia': ['.j'], 'r': ['.r'], 'cpp': ['.c', '.cpp', '.cxx', '.h', 'hpp']}

Configuration default values

include.settings.BL_DESCRIPTION = 'description'

Language version defaults

include.settings.BL_REQUIRED = set(['read', 'language'])

Separates Base CI (Travis) configurations from BLCI specific ones

include.settings.BL_SETTINGS = set(['code_loc', 'description', 'language', 'script', 'read', 'data_dep', 'data_loc', 'nthread', 'ignore', 'version', 'path', 'credentials', 'name'])

These are the default parameters blci uses

include.settings.GIT_IGNORE_FN = '.gitignore'

File types read by default by language

Module contents