diff --git a/frappe/__init__.py b/frappe/__init__.py index 7c62ae1808..a1efef535d 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -204,8 +204,13 @@ def msgprint(msg, small=0, raise_exception=0, as_table=False): def throw(msg, exc=ValidationError): msgprint(msg, raise_exception=exc) -def create_folder(path): - if not os.path.exists(path): os.makedirs(path) +def create_folder(path, with_init=False): + from frappe.utils import touch_file + if not os.path.exists(path): + os.makedirs(path) + + if with_init: + touch_file(os.path.join(path, "__init__.py")) def set_user(username): from frappe.utils.user import User diff --git a/frappe/utils/boilerplate.py b/frappe/utils/boilerplate.py index 80e7bd57ca..ae1b290e21 100644 --- a/frappe/utils/boilerplate.py +++ b/frappe/utils/boilerplate.py @@ -24,25 +24,18 @@ def make_boilerplate(dest): hooks[hook_key] = hook_val - frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, hooks.app_name)) - frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates")) + frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, frappe.scrub(hooks.app_title)), + with_init=True) + frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates"), with_init=True) frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", "statics")) frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", - "pages")) + "pages"), with_init=True) frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", - "generators")) - frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "config")) + "generators"), with_init=True) + frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "config"), with_init=True) - # init files touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "__init__.py")) - touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, hooks.app_name, "__init__.py")) - touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", "__init__.py")) - touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", - "pages", "__init__.py")) - touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "templates", - "generators", "__init__.py")) - touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "config", "__init__.py")) with open(os.path.join(dest, hooks.app_name, "MANIFEST.in"), "w") as f: f.write(manifest_template.format(**hooks)) @@ -62,7 +55,7 @@ def make_boilerplate(dest): f.write("License: " + hooks.app_license) with open(os.path.join(dest, hooks.app_name, hooks.app_name, "modules.txt"), "w") as f: - f.write(hooks.app_name) + f.write(hooks.app_title) with open(os.path.join(dest, hooks.app_name, hooks.app_name, "hooks.py"), "w") as f: f.write(hooks_template.format(**hooks))