forked from cruft/cruft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from i-dot-ai/EN-622/nested_templates
Add nested templates support
- Loading branch information
Showing
12 changed files
with
178 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def is_nested_template(context): | ||
return bool({"template", "templates"} & set(context["cookiecutter"].keys())) | ||
|
||
|
||
def get_relative_path(full_path_to_template, temporary_directory_root): | ||
"""Return the path of a nested template relative to the root of a given temporary directory.""" | ||
return full_path_to_template.split(temporary_directory_root + "/")[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from cruft.exceptions import UnableToFindCookiecutterTemplate | ||
|
||
|
||
def validate_cookiecutter(cookiecutter_template_dir: Path): | ||
main_cookiecutter_directory: Optional[Path] = None | ||
|
||
for dir_item in cookiecutter_template_dir.glob("*cookiecutter.*"): | ||
if dir_item.is_dir() and "{{" in dir_item.name and "}}" in dir_item.name: | ||
main_cookiecutter_directory = dir_item | ||
break | ||
|
||
if not main_cookiecutter_directory: | ||
raise UnableToFindCookiecutterTemplate(cookiecutter_template_dir) |
Oops, something went wrong.