-
Notifications
You must be signed in to change notification settings - Fork 1
/
gento.py
executable file
·135 lines (89 loc) · 2.55 KB
/
gento.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env python3
import argparse
import hashlib
import json
import logging
import os
import pickle
import time
import uuid
import pprint
logging.basicConfig(level=logging.DEBUG, filename='./debug.log', filemode='a')
logging.debug("start")
version = 0.1.1
issues_dir = "./issues"
class Issue(object):
def __init__(self, committer, text, status=None, issue_id=None):
self.committer = committer
self.text = text
if not status:
status = "open" # TODO Enum
self.status = status
created_at = int(time.time())
self.created_at = created_at
self.updated_at = created_at
if not issue_id:
issue_id = uuid.uuid4().hex
self.issue_id = issue_id
def save(self):
filename = issues_dir + "/" + self.issue_id
with open(filename, 'w') as issue_file:
json.dump(self.__dict__, issue_file)
def load(self):
pass
def get_comments(self):
pass
def show(self):
print("Issue: " + self.issue_id)
print(self.text)
def load(issue_id):
filename = issues_dir + "/" + issue_id
with open(filename, 'r') as issue_file:
issue = json.load(issue_file)
if not issue:
pass # TODO
i = Issue(issue['committer'], issue['text'], issue['status'], issue['issue_id'])
i.created_at = issue['created_at']
i.updated_at = issue['updated_at']
return i
class IssueComment(object):
def __init__(self, issue_id, text, commenter, created_at=None):
self.issue_id = issue_id
self.text = text
self.commenter = commenter
if not created_at:
created_at = int(time.time())
self.created_at = created_at
self.updated_at = created_at
def get_text(self):
pass
def main(args):
if args.list:
list_issues()
if args.issue_show:
i = Issue.load(args.issue_show)
i.show()
if args.issue_create:
i = Issue("Some User", args.issue_create)
i.save()
print("Created issue: " + i.issue_id)
return
def list_issues():
for issue_id in os.listdir(issues_dir):
filename = issues_dir + "/" + issue_id
with open(filename, 'r') as issue_file:
issue = json.load(issue_file)
if not issue:
pass # TODO
i = Issue(issue['committer'], issue['text'], issue['status'], issue['issue_id'])
i.created_at = issue['created_at']
i.updated_at = issue['updated_at']
i.show()
print("")
if __name__=="__main__":
parser = argparse.ArgumentParser(description="Track bugs in a Git repo")
parser.add_argument('-l', '--list', help="List all issues", action="store_true")
parser.add_argument('--issue-show', type=str, help="Show issue")
parser.add_argument('--issue-create', type=str, help="Create issue")
args = parser.parse_args()
main(args)