From f2a936c2e1d0c627ef6190ff63d251cf80424502 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:04:07 +0100 Subject: [PATCH] Revert "refactor: _create_app_boilerplate" This reverts commit 670d66210b943f75fcba512bd6814d16bb3c776a. --- frappe/utils/boilerplate.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frappe/utils/boilerplate.py b/frappe/utils/boilerplate.py index 0ce075b189..a36d64d74e 100644 --- a/frappe/utils/boilerplate.py +++ b/frappe/utils/boilerplate.py @@ -146,20 +146,24 @@ def _create_app_boilerplate(dest, hooks, no_git=False): with open(os.path.join(dest, hooks.app_name, hooks.app_name, "public", ".gitkeep"), "w") as f: f.write("") + with open(os.path.join(dest, hooks.app_name, hooks.app_name, "__init__.py"), "w") as f: + f.write(frappe.as_unicode(init_template)) + + with open(os.path.join(dest, hooks.app_name, "pyproject.toml"), "w") as f: + f.write(frappe.as_unicode(pyproject_template.format(**hooks))) + + with open(os.path.join(dest, hooks.app_name, ".pre-commit-config.yaml"), "w") as f: + f.write(frappe.as_unicode(precommit_template.format(**hooks))) + + with open(os.path.join(dest, hooks.app_name, "README.md"), "w") as f: + f.write(frappe.as_unicode(readme_template.format(**hooks))) + license_body = get_license_text(license_name=hooks.app_license) + with open(os.path.join(dest, hooks.app_name, "license.txt"), "w") as f: + f.write(frappe.as_unicode(license_body)) - TEMPLATE_MAP = { - "__init__.py": init_template, - "pyproject.toml": pyproject_template, - ".pre-commit-config.yaml": precommit_template, - "README.md": readme_template, - "license.txt": license_body, - "modules.txt": hooks.app_title, - } - - for filename, template in TEMPLATE_MAP.items(): - with open(os.path.join(dest, hooks.app_name, filename), "w") as f: - f.write(frappe.as_unicode(template.format(**hooks))) + with open(os.path.join(dest, hooks.app_name, hooks.app_name, "modules.txt"), "w") as f: + f.write(frappe.as_unicode(hooks.app_title)) # These values could contain quotes and can break string declarations # So escaping them before setting variables in setup.py and hooks.py