-
Notifications
You must be signed in to change notification settings - Fork 85
/
pull_request.py
67 lines (58 loc) · 2.18 KB
/
pull_request.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
"""
instructions, please do not alter the pull_reqesters.txt file
1. Run this file "python pull_request.py #username# #pet# #programming_language#"
replace the #...# above with your username
your favorite pet
your programming language
Thank you
@ibkvictor loves you
"""
import datetime
import sys
class pull_requester():
"""
here is a class of pull requester
it helps display the time of pull request
it also help display the github username of the requester
as well as pet, programming language id of the requester
"""
number_of_pull_requesters = 0
pull_requesters = {}
def __init__(self, data):
self.id = 0
self.gh_username = data[0]
self.pet = data[1]
self.language = data[2]
self.country = data[3]
self.date_time = datetime.datetime.now()
self.data = data
def made_pull_request_today(self):
"""
appends the new user to the pull_requesters.txt file update the record of users
prints out requesters informtaion
"""
#updates number of requesters
with open("pull_requesters.txt", "r") as file_reader:
nonempty_lines = [line.strip("\n") for line in file_reader if line != "\n"]
line_count = len(nonempty_lines)
self.number_of_pull_requesters = line_count - 1
self.id = self.number_of_pull_requesters + 1
with open("pull_requesters.txt", "a") as file_writer:
print(self.data)
file_writer.writelines("\n"+", ".join(self.data))
self.number_of_pull_requesters +=1
printer = """
your id: {}
your github username: {}
your favorite pet: {}
your favorite programming languages: {}
you are from the wonderful nation of: {}
the date you made the pull request: {}
Thank you for making this pull request. Have a lovely day.
""".format(self.id, self.gh_username, self.pet, self.language, self.country ,self.date_time)
self.pull_requesters[self.id] = printer
return printer
if __name__ =="__main__":
data = sys.argv[1:]
p = pull_requester(data)
print(p.made_pull_request_today())