copier_worker
¶
Tweaked version of the upstream copier functionality.
See the upstream: https://github.com/copier-org/copier/blob/259f351fc3c017c82b235888c119b9010d80494a/copier/main.py
| CLASS | DESCRIPTION |
|---|---|
NavaWorker |
Some (hopefully) small tweaks of upstream functionality. |
| FUNCTION | DESCRIPTION |
|---|---|
render_template_file |
Hackily render an individual file with the template settings. |
run_copy |
Copy a template to a destination, from zero. |
run_update |
Update a subproject, from its template. |
NavaWorker
dataclass
¶
NavaWorker(src_exclude: Sequence[str] = ())
Some (hopefully) small tweaks of upstream functionality.
Copier's upstream exclusion logic only runs against paths after they have
been rendered. This class supports exclusions based on the paths in the
template itself, before they have rendered, via src_exclude which can be
specified in the copier.yml file or as arguments in the API call.
| METHOD | DESCRIPTION |
|---|---|
__enter__ |
Allow using worker as a context manager. |
__exit__ |
Clean up garbage files after worker usage ends. |
render_template_file |
Render an individual file with the template settings. |
run_copy |
Generate a subproject from zero, ignoring what was in the folder. |
run_recopy |
Update a subproject, keeping answers but discarding evolution. |
run_update |
Update a subproject that was already generated. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
all_exclusions |
Combine default, template and user-chosen exclusions.
TYPE:
|
all_src_exclusions |
Combine template and user-chosen exclusions.
TYPE:
|
answers_relpath |
Obtain the proper relative path for the answers file.
TYPE:
|
jinja_env |
Return a pre-configured Jinja environment.
TYPE:
|
match_exclude |
Get a callable to match paths against all exclusions.
TYPE:
|
match_skip |
Get a callable to match paths against all skip-if-exists patterns.
TYPE:
|
match_src_exclude |
Get a callable to match paths against src file exclusions.
TYPE:
|
subproject |
Get related subproject.
TYPE:
|
template |
Get related template.
TYPE:
|
template_copy_root |
Absolute path from where to start copying.
TYPE:
|
all_exclusions
cached
property
¶
all_exclusions: Sequence[str]
Combine default, template and user-chosen exclusions.
all_src_exclusions
cached
property
¶
all_src_exclusions: Sequence[str]
Combine template and user-chosen exclusions.
answers_relpath
property
¶
answers_relpath: Path
Obtain the proper relative path for the answers file.
It comes from:
- User choice.
- Template default.
- Copier default.
jinja_env
cached
property
¶
jinja_env: SandboxedEnvironment
Return a pre-configured Jinja environment.
Respects template settings.
match_exclude
cached
property
¶
match_exclude: Callable[[Path], bool]
Get a callable to match paths against all exclusions.
match_skip
cached
property
¶
match_skip: Callable[[Path], bool]
Get a callable to match paths against all skip-if-exists patterns.
match_src_exclude
cached
property
¶
match_src_exclude: Callable[[Path], bool]
Get a callable to match paths against src file exclusions.
template_copy_root
cached
property
¶
template_copy_root: Path
Absolute path from where to start copying.
It points to the cloned template local abspath + the rendered subdir, if any.
__enter__
¶
__enter__() -> Self
Allow using worker as a context manager.
Source code in nava/platform/copier_worker.py
34 35 36 | |
__exit__
¶
__exit__(type: None, value: None, traceback: None) -> None
__exit__(
type: type[BaseException], value: BaseException, traceback: TracebackType
) -> None
__exit__(
type: type[BaseException] | None,
value: BaseException | None,
traceback: TracebackType | None,
) -> None
Clean up garbage files after worker usage ends.
Source code in copier/main.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
render_template_file
¶
render_template_file(
src_file_path: Path,
data: AnyByStrDict | None = None,
render_path: Path | None = None,
) -> None
Render an individual file with the template settings.
Source code in nava/platform/copier_worker.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
run_copy
¶
run_copy() -> None
Generate a subproject from zero, ignoring what was in the folder.
If dst_path was missing, it will be
created. Otherwise, src_path be rendered
directly into it, without worrying about evolving what was there
already.
See [generating a project][generating-a-project].
Source code in copier/main.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 | |
run_recopy
¶
run_recopy() -> None
Update a subproject, keeping answers but discarding evolution.
Source code in copier/main.py
858 859 860 861 862 863 864 865 866 | |
run_update
¶
run_update() -> None
Update a subproject that was already generated.
See updating a project.
Source code in copier/main.py
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | |
render_template_file
¶
render_template_file(
src_path: str,
src_file_path: StrOrPath,
dst_path: StrOrPath = ".",
render_path: StrOrPath | None = None,
data: AnyByStrDict | None = None,
**kwargs: Any,
) -> Worker
Hackily render an individual file with the template settings.
Source code in nava/platform/copier_worker.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
run_copy
¶
run_copy(
src_path: str,
dst_path: StrOrPath = ".",
data: AnyByStrDict | None = None,
**kwargs: Any,
) -> Worker
Copy a template to a destination, from zero.
Source code in nava/platform/copier_worker.py
84 85 86 87 88 89 90 91 92 93 94 95 | |
run_update
¶
run_update(
dst_path: StrOrPath = ".", data: AnyByStrDict | None = None, **kwargs: Any
) -> Worker
Update a subproject, from its template.
Source code in nava/platform/copier_worker.py
98 99 100 101 102 103 104 105 106 107 108 | |