refs #0 The root commit.
This commit is contained in:
35
back/core/command.py
Normal file
35
back/core/command.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from os import mkdir
|
||||
|
||||
|
||||
def create_project(name: str) -> None:
|
||||
"""
|
||||
Creates project folder and all required files.
|
||||
|
||||
from core import command; command.create_project("project")
|
||||
|
||||
Args:
|
||||
name (str): The desired project name.
|
||||
"""
|
||||
|
||||
def _create_file(
|
||||
file_name: str, # Literal["__init__", "config", "create_schema", "model", "schema"],
|
||||
content: str = None, # Optional[str] = None,
|
||||
) -> None:
|
||||
file = open("config/module/" + name + "/" + file_name, "w")
|
||||
if content:
|
||||
file.write(content)
|
||||
file.close()
|
||||
|
||||
mkdir("config/module/" + name)
|
||||
|
||||
files_without_content = ("__init__.py", "config.yaml")
|
||||
|
||||
files_with_content = ("create_schema.py", "model.py", "schema.py")
|
||||
|
||||
content = "from core.util import update_module_locals\n\nupdate_module_locals(__name__, locals())\n"
|
||||
|
||||
for file_name in files_without_content:
|
||||
_create_file(file_name)
|
||||
|
||||
for file_name in files_with_content:
|
||||
_create_file(file_name, content)
|
||||
Reference in New Issue
Block a user