34
34
from adabot import github_requests as github
35
35
36
36
# Setup ArgumentParser
37
- cmd_line_parser = argparse .ArgumentParser (description = "Adabot utility for updating circuitpython.org libraries info." ,
38
- prog = "Adabot circuitpython.org/libraries Updater" )
39
- cmd_line_parser .add_argument ("-o" , "--output_file" , help = "Output JSON file to the filename provided." ,
40
- metavar = "<OUTPUT FILENAME>" , dest = "output_file" )
37
+ cmd_line_parser = argparse .ArgumentParser (
38
+ description = "Adabot utility for updating circuitpython.org libraries info." ,
39
+ prog = "Adabot circuitpython.org/libraries Updater"
40
+ )
41
+ cmd_line_parser .add_argument (
42
+ "-o" , "--output_file" ,
43
+ help = "Output JSON file to the filename provided." ,
44
+ metavar = "<OUTPUT FILENAME>" ,
45
+ dest = "output_file"
46
+ )
41
47
42
48
def is_new_or_updated (repo ):
43
49
""" Check the repo for new release(s) within the last week. Then determine
@@ -55,20 +61,26 @@ def is_new_or_updated(repo):
55
61
if "published_at" not in release_info :
56
62
return
57
63
else :
58
- release_date = datetime .datetime .strptime (release_info ["published_at" ], "%Y-%m-%dT%H:%M:%SZ" )
64
+ release_date = datetime .datetime .strptime (
65
+ release_info ["published_at" ],
66
+ "%Y-%m-%dT%H:%M:%SZ"
67
+ )
59
68
if release_date < today_minus_seven :
60
69
return
61
70
62
- # we have a release within the last 7 days. now check if its a newly released library
63
- # within the last week, or if its just an update
71
+ # we have a release within the last 7 days. now check if its a newly
72
+ # released library within the last week, or if its just an update
64
73
result = github .get ("/repos/adafruit/" + repo ["name" ] + "/releases" )
65
74
if not result .ok :
66
75
return
67
76
68
77
new_releases = 0
69
78
releases = result .json ()
70
79
for release in releases :
71
- release_date = datetime .datetime .strptime (release ["published_at" ], "%Y-%m-%dT%H:%M:%SZ" )
80
+ release_date = datetime .datetime .strptime (
81
+ release ["published_at" ],
82
+ "%Y-%m-%dT%H:%M:%SZ"
83
+ )
72
84
if not release_date < today_minus_seven :
73
85
new_releases += 1
74
86
@@ -83,7 +95,8 @@ def get_open_issues_and_prs(repo):
83
95
open_issues = []
84
96
open_pull_requests = []
85
97
params = {"state" :"open" }
86
- result = github .get ("/repos/adafruit/" + repo ["name" ] + "/issues" , params = params )
98
+ result = github .get ("/repos/adafruit/" + repo ["name" ] + "/issues" ,
99
+ params = params )
87
100
if not result .ok :
88
101
return [], []
89
102
@@ -101,7 +114,8 @@ def get_contributors(repo):
101
114
reviewers = []
102
115
merged_pr_count = 0
103
116
params = {"state" :"closed" , "sort" :"updated" , "direction" :"desc" }
104
- result = github .get ("/repos/adafruit/" + repo ["name" ] + "/pulls" , params = params )
117
+ result = github .get ("/repos/adafruit/" + repo ["name" ] + "/pulls" ,
118
+ params = params )
105
119
if result .ok :
106
120
today_minus_seven = datetime .datetime .today () - datetime .timedelta (days = 7 )
107
121
prs = result .json ()
@@ -110,7 +124,8 @@ def get_contributors(repo):
110
124
if "merged_at" in pr :
111
125
if pr ["merged_at" ] is None :
112
126
continue
113
- merged_at = datetime .datetime .strptime (pr ["merged_at" ], "%Y-%m-%dT%H:%M:%SZ" )
127
+ merged_at = datetime .datetime .strptime (pr ["merged_at" ],
128
+ "%Y-%m-%dT%H:%M:%SZ" )
114
129
else :
115
130
continue
116
131
if merged_at < today_minus_seven :
@@ -137,10 +152,12 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
137
152
""" Clone the circuitpython-org repo, update libraries.json, and push the updates
138
153
in a commit.
139
154
"""
140
- if "TRAIVS " in os .environ :
155
+ if "TRAVIS " in os .environ :
141
156
if not os .path .isdir (cp_org_dir ):
142
157
os .makedirs (cp_org_dir , exist_ok = True )
143
- git_url = "https://" + os .environ ["ADABOT_GITHUB_ACCESS_TOKEN" ] + "@github.com/adafruit/circuitpython-org.git"
158
+ git_url = ("https://"
159
+ + os .environ ["ADABOT_GITHUB_ACCESS_TOKEN" ]
160
+ + "@github.com/adafruit/circuitpython-org.git" )
144
161
git .clone ("-o" , "adafruit" , git_url , cp_org_dir )
145
162
os .chdir (cp_org_dir )
146
163
git .pull ()
@@ -184,7 +201,9 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
184
201
working_directory = os .path .abspath (os .getcwd ())
185
202
cp_org_dir = os .path .join (working_directory , ".cp_org" )
186
203
187
- startup_message = ["Run Date: {}" .format (run_time .strftime ("%d %B %Y, %I:%M%p" ))]
204
+ startup_message = [
205
+ "Run Date: {}" .format (run_time .strftime ("%d %B %Y, %I:%M%p" ))
206
+ ]
188
207
189
208
output_filename = os .path .join (cp_org_dir , "_data/libraries.json" )
190
209
local_file_output = False
@@ -206,13 +225,21 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
206
225
merged_pr_count_total = 0
207
226
repos_by_error = {}
208
227
209
- default_validators = [vals [1 ] for vals in inspect .getmembers (cpy_vals .library_validator ) if vals [0 ].startswith ("validate" )]
228
+ default_validators = [
229
+ vals [1 ] for vals in inspect .getmembers (cpy_vals .library_validator )
230
+ if vals [0 ].startswith ("validate" )
231
+ ]
210
232
bundle_submodules = common_funcs .get_bundle_submodules ()
211
- validator = cpy_vals .library_validator (default_validators , bundle_submodules , 0.0 )
233
+ validator = cpy_vals .library_validator (
234
+ default_validators ,
235
+ bundle_submodules ,
236
+ 0.0
237
+ )
212
238
213
239
for repo in repos :
214
- if repo ["name" ] in cpy_vals .BUNDLE_IGNORE_LIST or repo ["name" ] == "circuitpython" :
215
- continue
240
+ if (repo ["name" ] in cpy_vals .BUNDLE_IGNORE_LIST
241
+ or repo ["name" ] == "circuitpython" ):
242
+ continue
216
243
repo_name = repo ["name" ]
217
244
218
245
# get a list of new & updated libraries for the last week
@@ -252,7 +279,9 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
252
279
else :
253
280
if error [0 ] not in repos_by_error :
254
281
repos_by_error [error [0 ]] = []
255
- repos_by_error [error [0 ]].append ("{0} ({1} days)" .format (repo ["html_url" ], error [1 ]))
282
+ repos_by_error [error [0 ]].append (
283
+ "{0} ({1} days)" .format (repo ["html_url" ], error [1 ])
284
+ )
256
285
257
286
# sort all of the items alphabetically
258
287
sorted_new_list = {}
0 commit comments