fabsetup.fabutils¶
Utils for invoke, fabric and fabsetup tasks.
fabsetup.fabutils.addon¶
Create and write local files in the context of a Fabsetup Addon.
- fabsetup.fabutils.addon.filled_out_template_str(template, **substitutions)¶
Return str template with applied substitutions.
- Example:
>>> template = '{{key}} = {{val}}' >>> filled_out_template_str(template, key='foo', val=42) 'foo = 42'
>>> template = '[[[foo]]] was substituted by {{foo}}' >>> filled_out_template_str(template, foo='bar') '{{foo}} was substituted by bar'
>>> template = 'names wrapped by {single} {curly} {braces} {{curly}}' >>> filled_out_template_str(template, curly='remain unchanged') 'names wrapped by {single} {curly} {braces} remain unchanged'
- fabsetup.fabutils.addon.filled_out_template(filename, **substitutions)¶
Return content of file filename with applied substitutions.
- fabsetup.fabutils.addon.template_context(from_path, package_name, substitutions)¶
- class fabsetup.fabutils.addon.Addon(module_dirname, context)¶
Bases:
object- property module_name¶
eg. ‘fabsetup_theno_termdown’
- property package_dirname¶
eg. ‘/home/theno/.fabsetup-addon-repos/fabsetup-theno-termdown’
- property package_name¶
eg. ‘fabsetup-theno-termdown’
- property files_basedir¶
eg. ‘/home/theno/.fabsetup-addon-repos/’ + ‘fabsetup-theno-termdown/fabsetup_theno_termdown/files’
- property downloads_basedir¶
eg. ‘/home/theno/.fabsetup-downloads/fabsetup-theno-termdown’
- install_file(path, sudo=False, local=False, from_path=None, **substitutions)¶
Install a file locally or on a remote host.
fabsetup.fabutils.queries¶
User interaction.
- fabsetup.fabutils.queries.interactive(prompt, cmd_color, prefill='')¶
- fabsetup.fabutils.queries.query_yes_no(question, default='yes')¶
Ask a yes/no question via input() and return their answer.
- Parameters:
question – A string that is presented to the user.
default – The presumed answer if the user just hits <Enter>. It must be ‘yes’ (the default), ‘no’, or None (which means an answer of the user is required).
The ‘answer’ return value is True for ‘yes’ or False for ‘no’.
This function originally comes from http://stackoverflow.com/a/3041990 and has been slightly changed.
- fabsetup.fabutils.queries.query_input(question, default=None, color=<function _wrap_with.<locals>.inner>)¶
Ask a question for input via input() and return their answer.
- Parameters:
question – A string that is presented to the user.
default – The presumed answer if the user just hits <Enter>.
color – Optionally set a color, default is
utils.colors.default_color
The ‘answer’ return value is a str.