-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyaml2excel.py
39 lines (31 loc) · 905 Bytes
/
yaml2excel.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
import os
import sys
from YamlReader import YamlReader
from ExcelWriter import ExcelWriter
def getYAMLPaths(targetDir):
names = os.listdir(targetDir)
names.sort()
yamlPaths = []
for name in names:
if name.endswith(".yaml") or name.endswith(".yml"):
yamlPaths.append(os.path.join(targetDir, name))
return yamlPaths
def makeBook(yamlPaths):
# make book
excel = ExcelWriter()
excel.makeBook('yaml.xlsx')
for path in yamlPaths:
#print("path={}".format(path))
dics = YamlReader().read(path)
excel.appendSheet(path, dics)
excel.close()
if __name__ == "__main__":
argvs = sys.argv
if len(argvs) != 2:
print("usage : python3 yaml2excel.py path")
sys.exit()
targetDir = argvs[1]
yamlPaths = getYAMLPaths(targetDir)
if len(yamlPaths) == 0:
sys.exit()
makeBook(yamlPaths)