Documentation for acme_project_create
acme_project_create._main
add_template_args(parser, template_dir_path)
Adds arguments to a parser using template_mani.configure_parser function in template directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser
|
ArgumentParser
|
The argument parser to which template arguments will be added. |
required |
template_dir_path
|
str
|
The path to the directory containing the template manifest. |
required |
Returns:
Type | Description |
---|---|
ArgumentParser
|
argparse.ArgumentParser: The parser with the template arguments added. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
copy_template_dir(template_dir_path)
Copies the contents of the specified template directory to a temporary directory, excluding 'template_manifest.py' and any __pycache__
directories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template_dir_path
|
str
|
The path to the template directory to be copied. |
required |
Returns:
Type | Description |
---|---|
TemporaryDirectory
|
tempfile.TemporaryDirectory: A temporary directory containing the copied contents. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the specified template directory does not exist |
move_to_target_dir(temp_dir, target_dir)
Moves all files and directories inside the temp directory to the target directory
render_template_dirs(target_dir, args)
Recursively finds and renames directories in the target directory that contain variables in their names.
This function searches through all directories within the specified target directory. If a directory name contains variables enclosed in double braces (e.g., {{variable}}), it replaces the double braces with single braces and formats the name using the provided arguments. The directory is then renamed to the new formatted name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_dir
|
str
|
The root directory to start the search. |
required |
args
|
object
|
An object containing the variables to be used for formatting the directory names. |
required |
Raises: KeyError: If a variable in the directory name is not found in the provided arguments.
render_template_files(target_dir, args)
Renders Jinja2 template files in the target directory.
This function searches for all files in the specified target directory that have a .j2template
extension,
renders them using the provided arguments, and saves the rendered content back to the same location without
the .j2template
extension. The original .j2template
files are removed after rendering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_dir
|
str
|
The directory to search for |
required |
args
|
Namespace
|
The arguments to use for rendering the templates. These should be passed as a Namespace object, where the attributes of the Namespace are used as variables in the templates. |
required |
Raises:
Type | Description |
---|---|
OSError
|
If there is an error reading or writing files in the target directory. |