-
Notifications
You must be signed in to change notification settings - Fork 1
/
pack_module.py
45 lines (32 loc) · 1.19 KB
/
pack_module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import logging, yaml, shutil, argparse
from git import Repo
def main():
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
parser = argparse.ArgumentParser(description='PyTG command line pack module utility')
parser.add_argument("--name")
parser.add_argument("--dest")
args = parser.parse_args()
if not args.name:
logging.error("No module specified")
return
if not args.dest:
logging.error("No destination specified")
return
source_folder = "modules/{}".format(args.name)
content_folder = "content/{}".format(args.name)
destination_folder = args.dest
logging.info("Packing module '{}' in folder {}...".format(args.name, args.dest))
# Copy source
logging.info("Copying source...")
shutil.copytree(source_folder, "{}/src".format(destination_folder))
# Copy content
logging.info("Copying content...")
try:
shutil.copytree(content_folder, "{}/dist_content".format(destination_folder))
except FileNotFoundError:
logging.warning("Couldn't copy content files, folder not found")
if __name__ == "__main__":
main()