forked from outlyerapp/packs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.py
executable file
·46 lines (35 loc) · 980 Bytes
/
create.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
#!/usr/bin/env python
import os
import sys
import errno
def make_node(node):
try:
os.makedirs(node)
except OSError, e:
if e.errno != errno.EEXIST:
raise
def create_node(f, times=None):
with open(f, 'a'):
os.utime(f, times)
def create_tree(h, c):
for dir, files in c.iteritems():
parent = os.path.join(h, dir)
make_node(parent)
children = c[dir]
for child in children:
child = os.path.join(parent, child)
create_node(child)
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Please specify a pack name"
sys.exit(2)
pack_name = sys.argv[1]
home = os.path.join(os.getcwd(), pack_name)
create_tree(home, {})
content = {
'': ['package.yaml', 'README.md'],
'plugins': [pack_name + '.py'],
'dashboards': [pack_name + '.yaml'],
'rules': [pack_name + '.yaml']
}
create_tree(home, content)