Преглед изворни кода

Module name based on app title and make init while creating folder

version-14
Nabin Hait пре 11 година
родитељ
комит
25f83d8f32
2 измењених фајлова са 14 додато и 16 уклоњено
  1. +7
    -2
      frappe/__init__.py
  2. +7
    -14
      frappe/utils/boilerplate.py

+ 7
- 2
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


+ 7
- 14
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))


Loading…
Откажи
Сачувај