yabs2
index
/home/jules/undo-work/home/jules/yabs/yabs2.py

Useful extensions and utilities for yabs.

 
Modules
       
inspect
os
re
string
sys
traceback
yabs
yabserrors

 
Functions
       
add_patternrule(target_pattern, pre_pattern, command_pattern, phony=False, root=None, autocmds=None, internal=0, always=False, categories=[], lockfilename=None, state=None)
Adds a rule similar to GNU make's % rules.
 
<target pattern> uses % to match any number of characters.
 
In both <pre_pattern> and <command_pattern>, %N is repaced by what
the Nth % matched in <target_pattern> (N=1,2,...); $@ is
replaced by the whole target. In <command_pattern> only, $^ is
replaced by the prerequisites, $< by the first prerequisite.
 
After % substitution, <pre_pattern> is split by spaces, and used as
the list of prerequisites.
 
Pattern replacement is crude at the moment - there is no escaping of
$ or % characters for example.
 
Instead of being a string, <command_pattern> can also be a function, taking
parameters ( target, prerequisites, match, context). <match> is the regex
match object for the target, <context>.out is where to send output text.
 
If <always> is true, the command is always run. This is the
equivalent to a raw yabs rule returning a prerequisite of None.
 
If <root> is None, it is set to the directory containing the caller's
module.
 
Any non-absolute paths implied by <target_pattern>, <pre_pattern>
and <command_pattern> are prefixed with <root>.
add_patternrule_phony(target_pattern, pre_pattern, command_pattern='', root=None, autocmds=None, internal=0, categories=[], lockfilename=None, state=None)
Like add_patternrule(), but rule is always registered as phony.
add_rules(regex, phony=False, root=None, autocmds=None, autodeps=None, state=None, module=None)
Looks for all functions in <module> whose names match <regex> (a
regex string or a compiled regex). If <module> is not specified, the
caller's module is used.
 
Matching functions that take two parameters are passed to
yabs.add_rule(), along with the optional <phony>, <root>,
<autocmds>, <autodeps> and <state> parameters.
appmake(argv=None, default_targets=None, default_params=None, default_build=None, state=None)
Behaves like GNU make.
 
Reads flags and targets from <argv>, and then makes each target.
Accepts yabs exceptions and converts them into an error message
and a non-zero return code. <Other exceptions are not caught>?. If
everything succeeds, returns 0.
 
<default_targets> can be a single target, or list/tuple of targets.
It is used as the target(s) if no target is specified in argv.
 
Similarly, <default_params> is either a command-line style
space-separated list of parameters or a list of parameters, and is
used if <argv> doesn't contain any parameters.
appmake2(state=None)
Expected to be called after readparams. Makes whatever targets are
have been specified. Calls yabs.handle_sighup(state) so that SIGHUP
will cause a diagnostic to be generated showing current state.
appmake2exit(state=None)
Expects to be called after readparams. Makes whatever targets are
have been specified, then calls sys.exit(0) or sys.exit(1).
appmakeexit(argv=None, default_targets=None, default_params=None, default_build=None, state=None)
Intended to be called from a Yabs build script.
 
As appmake(), but also calls sys.exit() with an appropriate
exit code.
compare_version_numbers(a, b)
Compares version tuples returned from make_version_numbers().
 
Returns +1, 0 or -1 depending on whether a is greater, the same
or less than b. a and b should be tuples of the form returned by
make_version_number().
insert_leafsubdir(filename, subdir)
Takes filename like foo/bar/pqr and returns foo/bar/<subdir>/pqr .
make_space_list(items)
Returns string consisting of each element in items preceded by
a space.
make_version_numbers(text)
Returns list of integers, from text assumed to be like "3.4.5".
`-' is also treated as a separator - e.g. gcc version strings can
be like `3.3.5-20050130'.
names_in_file(filename, regex)
Returns iterator for contents of file split first by line and then
split by using the second param as a regex.
readparams(argv=None, default_targets=None, default_params=None, default_build=None, state=None)
Reads GNU-style command-line parameters into state. The requested
targets are put into the list state.targets. Also, non-target
parameters are put into nontarget_args[]; this allows the original
command params to be reused with different targets.
split_dir(filename, directory)
Searches for element in <filename> called <directory>. Returns
tuple consisting of two lists, containing the directory elements
before and after <directory> in <filename>.
 
If <directory> isn't in <filename>, first item in tuple contains 
all elements of <filename>, second item is [].
 
Examples:
 
    search_for_dir_and_split(
            '/foo/bar/output/qwerty/abc.doc',
            'output')
    -> ( ['foo', 'bar'], [ 'qwerty', 'abc.doc'])
 
    search_for_dir_and_split(
            '/foo/bar/output/qwerty/abc.doc',
            'xyzqwerty')
    -> ( [ 'foo', 'bar', 'qwerty', 'abc.doc'], [])

 
Data
        appmake_help = "Yabs options are:\n\n -b <build>\n Se...hat doesn't start with `-' is taken as a target.\n"
generators = _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 0)
separator = ','