Warning
Python API is far from being “frozen”, use it with zero backwards-compatibility in mind. You are welcome to report suggestions to bug tracker.
Bases: object
Controller that figures out settings, asks questions and renders the directory structure.
Parameters: |
|
---|
Additional to above settings, Configurator exposes following attributes:
Render file structure given instance configuration. Basically calls mrbob.rendering.render_structure().
Bases: object
Question configuration. Parameters are used to configure questioning and possible validation of the answer.
Parameters: |
|
---|
Any of above parameters can be accessed as an attribute of Question instance.
Eventually, ask the question.
Parameters: | configurator – mrbob.configurator.Configurator instance |
---|
mr.bob exceptions module.
Bases: mrbob.exceptions.MrBobError
Raised during configuration phase
Bases: mrbob.exceptions.MrBobError
Raised during pre_ask_question if we should skip it
Bases: mrbob.exceptions.ConfigurationError
Raised reading template configuration
Bases: mrbob.exceptions.MrBobError
Raised during question validation
Recursively copies the given filesystem path fs_source_root_ to a target directory `fs_target_root.
Any files ending in .bob are rendered as templates using the given renderer using the variables dictionary, thereby losing the .bob suffix.
strings wrapped in + signs in file- or directory names will be replaced with values from the variables, i.e. a file named +name+.py.bob given a dictionary {‘name’: ‘bar’} would be rendered as bar.py.
Use any of hooks below or write your own. You are welcome to contribute them!
If you want to display a message to the user when rendering is complete, you can use this function as Post render hook:
[template]
post_render = mrbob.hooks:show_message
message = Well done, %(author.name)s, your code is ready!
As shown above, you can use standard Python formatting in post_render_msg.
If you want to convert an answer to Python boolean, you can use this function as Post question hook:
[questions]
idiot.question = Are you young?
idiot.post_ask_question = mrbob.hooks:to_boolean
Following variables can be converted to a boolean: y, n, yes, no, true, false, 1, 0