Sfoglia il codice sorgente

can now select destination for boilerplate

version-14
Pratik Vyas 11 anni fa
parent
commit
11f1b3f00d
2 ha cambiato i file con 29 aggiunte e 29 eliminazioni
  1. +3
    -3
      frappe/cli.py
  2. +26
    -26
      frappe/utils/boilerplate.py

+ 3
- 3
frappe/cli.py Vedi File

@@ -124,7 +124,7 @@ def setup_parser():
return parser.parse_args()

def setup_install(parser):
parser.add_argument("--make_app", default=False, action="store_true",
parser.add_argument("--make_app", metavar="DEST", nargs=1,
help="Make a new application with boilerplate")
parser.add_argument("--install", metavar="DB-NAME", nargs=1,
help="Install a new db")
@@ -261,9 +261,9 @@ def setup_translation(parser):

# methods
@cmd
def make_app():
def make_app(destination):
from frappe.utils.boilerplate import make_boilerplate
make_boilerplate()
make_boilerplate(destination)

@cmd
def use(sites_path):


+ 26
- 26
frappe/utils/boilerplate.py Vedi File

@@ -6,9 +6,9 @@ from __future__ import unicode_literals
import frappe, os
from frappe.utils import touch_file

def make_boilerplate():
if not os.path.exists("sites"):
print "Run from bench! (sites folder must exist)"
def make_boilerplate(dest):
if not os.path.exists(dest):
print "Destination directory does not exist"
return
hooks = frappe._dict()
@@ -24,52 +24,52 @@ def make_boilerplate():
hooks[hook_key] = hook_val
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, hooks.app_name))
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, "templates"))
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, "templates",
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, "templates",
"statics"))
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, "templates",
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates",
"pages"))
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, "templates",
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "templates",
"generators"))
frappe.create_folder(os.path.join(hooks.app_name, hooks.app_name, "config"))
frappe.create_folder(os.path.join(dest, hooks.app_name, hooks.app_name, "config"))
# init files
touch_file(os.path.join(hooks.app_name, hooks.app_name, "__init__.py"))
touch_file(os.path.join(hooks.app_name, hooks.app_name, hooks.app_name, "__init__.py"))
touch_file(os.path.join(hooks.app_name, hooks.app_name, "templates", "__init__.py"))
touch_file(os.path.join(hooks.app_name, hooks.app_name, "templates",
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(hooks.app_name, hooks.app_name, "templates",
touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "templates",
"generators", "__init__.py"))
touch_file(os.path.join(hooks.app_name, hooks.app_name, "config", "__init__.py"))
touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "config", "__init__.py"))
with open(os.path.join(hooks.app_name, "MANIFEST.in"), "w") as f:
with open(os.path.join(dest, hooks.app_name, "MANIFEST.in"), "w") as f:
f.write(manifest_template.format(**hooks))

with open(os.path.join(hooks.app_name, ".gitignore"), "w") as f:
with open(os.path.join(dest, hooks.app_name, ".gitignore"), "w") as f:
f.write(gitignore_template)

with open(os.path.join(hooks.app_name, "setup.py"), "w") as f:
with open(os.path.join(dest, hooks.app_name, "setup.py"), "w") as f:
f.write(setup_template.format(**hooks))

with open(os.path.join(hooks.app_name, "requirements.txt"), "w") as f:
with open(os.path.join(dest, hooks.app_name, "requirements.txt"), "w") as f:
f.write("frappe")

touch_file(os.path.join(hooks.app_name, "README.md"))
touch_file(os.path.join(dest, hooks.app_name, "README.md"))

with open(os.path.join(hooks.app_name, "license.txt"), "w") as f:
with open(os.path.join(dest, hooks.app_name, "license.txt"), "w") as f:
f.write("License: " + hooks.app_license)

with open(os.path.join(hooks.app_name, hooks.app_name, "modules.txt"), "w") as f:
with open(os.path.join(dest, hooks.app_name, hooks.app_name, "modules.txt"), "w") as f:
f.write(hooks.app_name)

with open(os.path.join(hooks.app_name, hooks.app_name, "hooks.txt"), "w") as f:
with open(os.path.join(dest, hooks.app_name, hooks.app_name, "hooks.txt"), "w") as f:
f.write(hooks_template.format(**hooks))

touch_file(os.path.join(hooks.app_name, hooks.app_name, "patches.txt"))
touch_file(os.path.join(dest, hooks.app_name, hooks.app_name, "patches.txt"))

with open(os.path.join(hooks.app_name, hooks.app_name, "config", "desktop.py"), "w") as f:
with open(os.path.join(dest, hooks.app_name, hooks.app_name, "config", "desktop.py"), "w") as f:
f.write(desktop_template.format(**hooks))
@@ -138,4 +138,4 @@ gitignore_template = """.DS_Store
*.pyc
*.egg-info
*.swp
tags"""
tags"""

Caricamento…
Annulla
Salva