91 lines
1.6 KiB
Python
Executable file
91 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import os as _os
|
|
import shutil as _shutil
|
|
import argparse as _argparse
|
|
|
|
|
|
def main():
|
|
## consts
|
|
conf = {
|
|
"dir_lib": "lib",
|
|
"dir_source": "source",
|
|
"dir_logic": "logic",
|
|
}
|
|
|
|
## args
|
|
argument_parser = _argparse.ArgumentParser(
|
|
)
|
|
argument_parser.add_argument(
|
|
"-o",
|
|
"--output-directory",
|
|
default = "/tmp/davina",
|
|
type = str,
|
|
metavar = "<output-directory>",
|
|
)
|
|
argument_parser.add_argument(
|
|
"-c",
|
|
"--conf-path",
|
|
default = None,
|
|
type = str,
|
|
metavar = "<conf-path>",
|
|
)
|
|
args = argument_parser.parse_args()
|
|
|
|
## exec
|
|
### exec:directories
|
|
if True:
|
|
_os.makedirs(
|
|
args.output_directory,
|
|
exist_ok = True
|
|
)
|
|
_os.makedirs(
|
|
_os.path.join(args.output_directory, "data"),
|
|
exist_ok = True
|
|
)
|
|
_os.makedirs(
|
|
_os.path.join(args.output_directory, "public"),
|
|
exist_ok = True
|
|
)
|
|
### exec:libs
|
|
if True:
|
|
_shutil.copytree(
|
|
_os.path.join(conf["dir_lib"], "composer"),
|
|
args.output_directory,
|
|
dirs_exist_ok = True
|
|
)
|
|
### exec:sources
|
|
if True:
|
|
_shutil.copytree(
|
|
conf["dir_source"],
|
|
_os.path.join(args.output_directory, conf["dir_logic"]),
|
|
dirs_exist_ok = True
|
|
)
|
|
### exec:index
|
|
if True:
|
|
path = _os.path.join(args.output_directory, "index.php")
|
|
if (not _os.path.exists(path)):
|
|
pass
|
|
else:
|
|
_os.remove(
|
|
path
|
|
)
|
|
_os.symlink(
|
|
_os.path.join(conf["dir_logic"], "main.php"),
|
|
path
|
|
)
|
|
### exec:conf
|
|
if True:
|
|
if (args.conf_path is None):
|
|
pass
|
|
else:
|
|
_shutil.copy(
|
|
args.conf_path,
|
|
_os.path.join(args.output_directory, "conf.json")
|
|
)
|
|
print(args.output_directory)
|
|
|
|
|
|
main()
|
|
|