From 63ee591d6a997f55a5a53b0d010b600bb5b4bf56 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Fri, 1 Oct 2021 04:23:31 +0400 Subject: [PATCH] Fixed resource cleanup. (#24) Closes #21. Signed-off-by: Pavel Kirilin <win10@list.ru> --- fastapi_template/template/hooks/post_gen_project.py | 7 ++++--- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fastapi_template/template/hooks/post_gen_project.py b/fastapi_template/template/hooks/post_gen_project.py index 76f2399..9479917 100644 --- a/fastapi_template/template/hooks/post_gen_project.py +++ b/fastapi_template/template/hooks/post_gen_project.py @@ -8,7 +8,7 @@ from pygit2 import init_repository from termcolor import cprint, colored from pathlib import Path -MANIFEST = "conditional_files.json" +CONDITIONAL_MANIFEST = "conditional_files.json" REPLACE_MANIFEST = "replaceable_files.json" @@ -20,7 +20,7 @@ def delete_resource(resource): def delete_resources_for_disabled_features(): - with open(MANIFEST) as manifest_file: + with open(CONDITIONAL_MANIFEST) as manifest_file: manifest = json.load(manifest_file) for feature_name, feature in manifest.items(): if feature["enabled"].lower() != "true": @@ -31,7 +31,7 @@ def delete_resources_for_disabled_features(): print(text) for resource in feature["resources"]: delete_resource(resource) - delete_resource(MANIFEST) + delete_resource(CONDITIONAL_MANIFEST) cprint("cleanup complete!", color="green") @@ -49,6 +49,7 @@ def replace_resources(): for src_file in map(Path, replaces): if src_file.exists(): shutil.move(src_file, target_path) + delete_resource(REPLACE_MANIFEST) print( "Resources are happy to be where {}.".format( colored("they are needed the most", color="green", attrs=["underline"]) diff --git a/pyproject.toml b/pyproject.toml index 3d5e1e1..b49430c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fastapi_template" -version = "3.1.0" +version = "3.1.1" description = "Feature-rich robust FastAPI template" authors = ["Pavel Kirilin <win10@list.ru>"] packages = [{ include = "fastapi_template" }] -- GitLab