API¶
Welcome to the API of Pymaker!
Exceptions¶
-
exception
pymaker.RecursiveDefinitionError¶ An error raised when a recursive definition is detected.
Public Functions¶
-
@pymaker.command(command, deps)¶ Define a command. Dependencies can be declared through the
depsargument. Help for that command can be defined through the docstring. A command name can be provided through thenameoption, but it defaults to the function’s name, which is probably what you want. Example:@command def fn(): "This is a help string." pass @command(deps=['fn']) def fn2(): pass @command(name='notme') def fn3(): pass
-
pymaker.declare_argument(*args, **kwargs)¶ Declare a command-line argument. Acts as a wrapper around
argparse.ArgumentParser.add_argument.
-
pymaker.r(s)¶ Run a command. This is a wrapper for either
os.systemorsubprocess.call, depending on whether the argument is a string or a list. Example:>>> r('echo "This is a test"') Pymaker: echo "This is a test" This is a test >>> r(['echo', 'This is a test']) Pymaker: echo This is a test This is a test
Use this function instead of
os.systemorsubprocess.callwhen calling shell commands.
-
pymaker.main(filename='Makefile.py')¶ Main function. Can be added like so to make any file a Makefile:
main(__file__)
Then, you can run that file like a Makefile by doing
python <filename> <command>.
Private Functions¶
-
pymaker.build_direc(filename)¶ Builds a directory of all commands.
-
pymaker.call_command(command, direc, ns)¶ Call a command, given a command name, a directory, and a namespace object.
-
pymaker.make_help_message(direc)¶ Makes a help message from the Makefile.py present in the directory.