forked from Paraphory/GitHub-Labels-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanager.py
49 lines (37 loc) · 1.04 KB
/
manager.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
import os
import sys
import json
from models.label import label
import models.template as template
def generateDefaultTemplates():
labels = template.labelsTemplate.default()
with open("templates/labels.json", "w") as file:
file.write(labels.toJson())
def applyTemplate(index):
templateFile = ''
target = ''
owner = ''
repo = ''
for i in range(index, len(sys.argv)):
if sys.argv[i].lower() == "--target":
target = sys.argv[i + 1]
break
else:
templateFile = sys.argv[i]
if target.__contains__("/"):
parts = target.split("/")
owner = parts[0]
repo = parts[1]
else:
owner = target
if templateFile != '':
path = 'templates/' + templateFile
instance = template.labelsTemplate.build(path)
if instance == '':
return
if repo != '':
instance.apply(owner, repo)
else:
instance.applyToRepos(owner)
if __name__ == "__main__":
generateDefaultTemplates()