pyprec package
Subpackages
Submodules
pyprec.export module
This module
- pyprec.export.create_folder_tree(prefix_folder: Path, source_folder: Path)[source]
Creates the source directory tree.
Directory tree is:
root |-- source_folder # ``src/<pkgname>`` | |-- scripts | |-- utils
- Parameters
prefix_folder (Path) – The package root folder.
source_folder (Path) – The folder to create the package source files to.
- Raises
FileExistsError – If the source directory already exists.
pyprec.pyexporter module
- class pyprec.pyexporter.PyExporter(input_path: Path)[source]
Bases:
objectClass providing templating utilities.
Example
Loading a template from a
.incfile:>>> from pyprec.pyexporter import PyExporter >>> exporter = PyExporter("foo.inc") >>> exporter.fill(replace_dict) >>> exporter.write("foo.py")
- pyprec.pyexporter.load_fill_and_export(template_path: Path, setup: dict, output_path: Path)[source]
Wrapper function that loads a template file, fills and writes it to file.
- Parameters
template_path (Path) – The input template file path.
setup (dict) – The key-value pairs to be inserted in the template fields.
output_path (Path) – The output file path.
pyprec.ui module
This module implements the pyprec user interface.
- pyprec.ui.ask_question_list(logger: Logger, questions: list[Tuple[str, str, Any]], timeout: float) dict[source]
Asks interactively to edit the runcard.
Receives the input from the user and opens an editor in the terminal as a subprocess. Default editor is nano, otherwise the QUAKE_EDITOR environment variable allows for custom choice.
- Parameters
logger (logging.Logger) – The logger instance.
questions (list[Tuple[str, str, Any]) – List of tuples containing (key, question, default answer).
timeout (float) – Time limit to answer in seconds.
- Returns
setup – The key-value pairs to be inserted in the template fields.
- Return type
dict
- pyprec.ui.get_question_list() list[Tuple[str, str, Any]][source]
Returns the list of questions to be asked to the user with default values.
- Returns
questions – List of tuples containing (key, question, default answer).
- Return type
list[Tuple[str, str, Any]]
- pyprec.ui.load_setup_from_runcard(runcard_file: Path) dict[source]
Load runcard from yaml file.
- Parameters
runcard_file (Path) – The yaml to load the dictionary from.
- Returns
runcard – The loaded settings dictionary.
- Return type
dict
Module contents
Package source root directory.