-
Notifications
You must be signed in to change notification settings - Fork 0
/
barrancas.py
executable file
·57 lines (47 loc) · 1.31 KB
/
barrancas.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
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
import argparse
import sys
import yaml
from path import Path
from yaml import CLoader
from barrancas.generator import Generator
from barrancas.server import Server
CONFIG = {
"port": 8000,
}
def main():
try:
properties_f = Path("conf.yml").read_text()
properties = yaml.load(properties_f, Loader=CLoader)
CONFIG.update(properties)
except:
pass
parser = argparse.ArgumentParser()
parser.add_argument(
"--server", metavar="PORT", nargs="?", default=None, type=int, required=False
)
parser.add_argument(
"--directory", metavar="DIRECTORY", default=None, type=str, required=False
)
parser.add_argument("--generate", action="store_true")
args = parser.parse_args()
if len(sys.argv) > 1:
if args.server or args.server is None:
port = CONFIG["port"]
if not args.server is None:
port = args.server
if args.directory:
directory = args.directory
else:
directory = "."
s = Server(port, directory)
s.start()
if args.generate:
g = Generator(CONFIG)
g.generate()
else:
g = Generator(CONFIG)
g.generate()
if __name__ == "__main__":
main()
sys.exit(0)