33
33
34
34
REPO = input ("repo name: " )
35
35
dirname = input ("path to repo: " )
36
+ LINK = "https://api.github.com/repos/chaoss/"
36
37
37
38
38
39
def getlistoffiles (dirname ):
@@ -67,10 +68,9 @@ def main():
67
68
api_func (item , dirname )
68
69
69
70
70
- def api_func (items2 , dirname ):
71
- PATH_TO_FILE2 = items2 .replace (dirname , '' )
71
+ def api_func (file_name , dirname ):
72
+ PATH_TO_FILE2 = file_name .replace (dirname , '' )
72
73
PATH_TO_FILE = PATH_TO_FILE2 .strip ('/' )
73
- LINK = "https://api.github.com/repos/chaoss/"
74
74
75
75
data = requests .get (LINK + REPO + "/commits?path=" + PATH_TO_FILE )
76
76
@@ -89,7 +89,7 @@ def api_func(items2, dirname):
89
89
authors = [key + " <" + value + ">" for key , value in authors_data .items ()]
90
90
authors .append ('' )
91
91
92
- # print(authors)
92
+ print (authors )
93
93
94
94
template_file = open ("gpl-v3.tmpl" )
95
95
@@ -103,21 +103,21 @@ def api_func(items2, dirname):
103
103
104
104
result = src .substitute (sub_dict )
105
105
106
- with open (items2 , 'r' ) as f :
106
+ with open (file_name , 'r' ) as f :
107
107
contents = f .readlines ()
108
108
i = 0
109
109
for item in contents :
110
110
if item .startswith ('#' ):
111
111
i += 1
112
112
113
- with open (items2 , 'w' ) as f :
113
+ with open (file_name , 'w' ) as f :
114
114
f .writelines (contents [i :])
115
115
116
- with open (items2 , 'r' ) as f :
116
+ with open (file_name , 'r' ) as f :
117
117
contents = f .readlines ()
118
118
contents .insert (0 , result + "\n " )
119
119
120
- with open (items2 , 'w' ) as f :
120
+ with open (file_name , 'w' ) as f :
121
121
contents = "" .join (contents )
122
122
f .write (contents )
123
123
0 commit comments