dktasklib package

Submodules

dktasklib.clean module

dktasklib.commands module

class dktasklib.commands.Command(name, argspec='', requirements=(), policy={'list_join': ', ', 'negative_bool': 'omit'}, **optdefs)[source]

Bases: object

dktasklib.concat module

dktasklib.concat.chomp(s)[source]

Remove line terminator if it exists.

dktasklib.concat.concat(ctx, dest, *sources, **kw)[source]
dktasklib.concat.copy(ctx, source, dest, force=False)[source]

Copy source to dest, which can be a file or directory.

dktasklib.concat.fix_line_endings(fname, eol='\n')[source]

Change all line endings to eol.

dktasklib.concat.line_endings(fname)[source]

Return all line endings in the file.

dktasklib.docs module

dktasklib.environment module

Global state.

class dktasklib.environment.Environment[source]

Bases: object

dktasklib.executables module

class dktasklib.executables.Executables[source]

Bases: object

Class for finding executables on the host system.

ctx
find(name, requires=(), install_txt='')[source]

Find the executable named name on the PATH.

Parameters:
  • name (str) – name of executable to find.
  • requires (List[str]) – list of executables to find first.
  • install_txt (str) – instructions for how to install the executable if it is not found.
find_babel()[source]
find_babili()[source]
find_browserify()[source]
find_nodejs()[source]

Find node.

find_npm()[source]

Find the node package manager (npm).

find_twine()[source]
find_uglify()[source]
find_wheel()[source]
require(*dependencies)[source]

Ensure that all dependencies are available. You should not need to call this yourself, use the requires() decorator instead.

exception dktasklib.executables.MissingCommand[source]

Bases: exceptions.Exception

Exception thrown when a command (executable) is not found.

dktasklib.executables.exe = <dktasklib.executables.Executables object>

public interface to the Executables class

dktasklib.executables.requires(*deps)[source]

Decorator to declare global dependencies/requirements.

Usage (@task must be last):

@requires('nodejs', 'npm', 'lessc')
@task
def mytask(..)

dktasklib.help module

dktasklib.jstools module

dktasklib.lessc module

dktasklib.manage module

dktasklib.npm module

dktasklib.npm.global_package(pkgname)[source]

Check if an npm package is installed globally.

dktasklib.npm.npm(cmdline)[source]

dktasklib.pset module

class dktasklib.pset.pset(items=(), **attrs)[source]

Bases: dict

Property Set class. A property set is an object where values are attached to attributes, but can still be iterated over as key/value pairs. The order of assignment is maintained during iteration. Only one value allowed per key.

>>> x = pset()
>>> x.a = 42
>>> x.b = 'foo'
>>> x.a = 314
>>> x
pset(a=314, b='foo')
__add__(other)[source]

self + other

__eq__(other)[source]

Equal iff they have the same set of keys, and the values for each key is equal. Key order is not considered for equality.

__radd__(other)[source]

other + self

items()[source]
keys()[source]
remove(key)[source]

Remove key from client vars.

values()[source]

dktasklib.publish module

dktasklib.rule module

class dktasklib.rule.BuildRule(*args, **kwargs)[source]

Bases: object

after = []
needs_to_run()[source]
requires = []
run(ctx)[source]
topsort(tasklist)[source]

Topological sort

dktasklib.runners module

class dktasklib.runners.Result[source]

Bases: str

cmd = None
returncode = None
dktasklib.runners.command(executable, dryrun=False)[source]
dktasklib.runners.run(cmdline, throw=False)[source]

dktasklib.upversion module

Update a package’s version number.

class dktasklib.upversion.UpdateTemplateVersion(*args, **kwargs)[source]

Bases: dktasklib.rule.BuildRule

dktasklib.upversion.files_with_version_numbers()[source]

dktasklib.urlinliner module

dktasklib.urlinliner.inline_data(data, type='image/png', name='')[source]

Inline (encode) the data.

dktasklib.urlinliner.inline_file(fname)[source]

Inline from a file source named fname.

dktasklib.urlinliner.inline_url(uri)[source]

Fetch uri and inline.

dktasklib.utils module

dktasklib.utils.cd(*args, **kwds)[source]

Context manager to change directory.

Usage:

with cd('foo/bar'):
    # current directory is now foo/bar
# current directory restored.
dktasklib.utils.dest_is_newer_than_source(src, dst)[source]

Check if destination is newer than source.

Usage:

if not force and dest_is_newer_than_source(source, dest):
    print 'babel:', dest, 'is up-to-date.'
    return dest
dktasklib.utils.env(*args, **kwds)[source]

Context amanger to temporarily override environment variables.

dktasklib.utils.filename(fname)[source]

Return only the file name (removes the path)

dktasklib.utils.find_pymodule(dotted_name)[source]

Find the directory of a python module, without importing it.

dktasklib.utils.fmt(s, ctx)[source]

Use the mapping ctx as a formatter for the {new.style} formatting string s.

dktasklib.utils.message(*args, **kwds)[source]
dktasklib.utils.switch_extension(fname, ext='', old_ext=None)[source]

Switch file extension on fname to ext. Returns the resulting file name.

Usage:

switch_extension('a/b/c/d.less', '.css')

dktasklib.version module

dktasklib.version.add_version(ctx, source, outputdir=None, kind='pkg', force=False)

Copy source with version number to outputdir.

The version type is specified by the kind parameter and can be either “pkg” (package version), “svn” (current subversion revision number), or “hash” (the md5 hash of the file’s contents).

Returns:(str) output file name
dktasklib.version.copy_to_version(ctx, source, outputdir=None, kind='pkg', force=False)[source]

Copy source with version number to outputdir.

The version type is specified by the kind parameter and can be either “pkg” (package version), “svn” (current subversion revision number), or “hash” (the md5 hash of the file’s contents).

Returns:(str) output file name
dktasklib.version.get_version(ctx, fname, kind='pkg')[source]

Return the version number for fname.

dktasklib.version.min_name(fname, min='.min')[source]

Adds a .min extension before the last file extension.

dktasklib.version.version_name(fname)

Returns a template string containing {version} in the correct place.

dktasklib.version.versioned_name(fname)[source]

Returns a template string containing {version} in the correct place.

dktasklib.watch module

Usage:

@task
def watch(ctx):
    watcher = Watcher(ctx)
    watcher.watch_file(
        name='{pkg.source}/less/{pkg.name}.less',
        action=lambda e: build(ctx, less=True)
    )
    watcher.watch_directory(
        path='{pkg.source}/js', ext='.jsx',
        action=lambda e: build(ctx, js=True)
    )
    watcher.watch_directory(
        path='{pkg.docs}', ext='.rst',
        action=lambda e: build(ctx, docs=True)
    )
    watcher.start()

ns = Collection(..., watch, ...)
ns.configure({
    'pkg': Package()
})
class dktasklib.watch.DirectoryModified(ctx, path, ext, action)[source]

Bases: watchdog.events.FileSystemEventHandler

on_modified(event)[source]
class dktasklib.watch.FileModified(ctx, fname, action)[source]

Bases: watchdog.events.FileSystemEventHandler

on_modified(event)[source]
class dktasklib.watch.Watcher(ctx)[source]

Bases: object

start()[source]
watch_directory(path, ext, action)[source]
watch_file(name, action)[source]

dktasklib.wintask module

dktasklib.wintask.task(*args, **kwargs)[source]

Marks wrapped callable object as a valid Invoke task.

May be called without any parentheses if no extra options need to be specified. Otherwise, the following keyword arguments are allowed in the parenthese’d form:

  • name: Default name to use when binding to a .Collection. Useful for avoiding Python namespace issues (i.e. when the desired CLI level name can’t or shouldn’t be used as the Python level name.)
  • aliases: Specify one or more aliases for this task, allowing it to be invoked as multiple different names. For example, a task named mytask with a simple @task wrapper may only be invoked as "mytask". Changing the decorator to be @task(aliases=['myothertask']) allows invocation as "mytask" or "myothertask".
  • positional: Iterable overriding the parser’s automatic “args with no default value are considered positional” behavior. If a list of arg names, no args besides those named in this iterable will be considered positional. (This means that an empty list will force all arguments to be given as explicit flags.)
  • optional: Iterable of argument names, declaring those args to have optional values. Such arguments may be given as value-taking options (e.g. --my-arg=myvalue, wherein the task is given "myvalue") or as Boolean flags (--my-arg, resulting in True).
  • iterable: Iterable of argument names, declaring them to build iterable values.
  • incrementable: Iterable of argument names, declaring them to increment their values.
  • default: Boolean option specifying whether this task should be its collection’s default task (i.e. called if the collection’s own name is given.)
  • auto_shortflags: Whether or not to automatically create short flags from task options; defaults to True.
  • help: Dict mapping argument names to their help strings. Will be displayed in --help output.
  • pre, post: Lists of task objects to execute prior to, or after, the wrapped task whenever it is executed.
  • autoprint: Boolean determining whether to automatically print this task’s return value to standard output when invoked directly via the CLI. Defaults to False.
  • klass: Class to instantiate/return. Defaults to .Task.

If any non-keyword arguments are given, they are taken as the value of the pre kwarg for convenience’s sake. (It is an error to give both *args and pre at the same time.)

New in version 1.0.

Changed in version 1.1: Added the klass keyword argument.

Module contents