Skip to content

Commit ed8c7ea

Browse files
authored
Merge pull request #91 from sommersoft/traivs_unknown
Fix Typo For CP.org Script
2 parents ab1ccd0 + edde947 commit ed8c7ea

File tree

1 file changed

+48
-19
lines changed

1 file changed

+48
-19
lines changed

adabot/update_cp_org_libraries.py

+48-19
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@
3434
from adabot import github_requests as github
3535

3636
# 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+
)
4147

4248
def is_new_or_updated(repo):
4349
""" Check the repo for new release(s) within the last week. Then determine
@@ -55,20 +61,26 @@ def is_new_or_updated(repo):
5561
if "published_at" not in release_info:
5662
return
5763
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+
)
5968
if release_date < today_minus_seven:
6069
return
6170

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
6473
result = github.get("/repos/adafruit/" + repo["name"] + "/releases")
6574
if not result.ok:
6675
return
6776

6877
new_releases = 0
6978
releases = result.json()
7079
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+
)
7284
if not release_date < today_minus_seven:
7385
new_releases += 1
7486

@@ -83,7 +95,8 @@ def get_open_issues_and_prs(repo):
8395
open_issues = []
8496
open_pull_requests = []
8597
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)
87100
if not result.ok:
88101
return [], []
89102

@@ -101,7 +114,8 @@ def get_contributors(repo):
101114
reviewers = []
102115
merged_pr_count = 0
103116
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)
105119
if result.ok:
106120
today_minus_seven = datetime.datetime.today() - datetime.timedelta(days=7)
107121
prs = result.json()
@@ -110,7 +124,8 @@ def get_contributors(repo):
110124
if "merged_at" in pr:
111125
if pr["merged_at"] is None:
112126
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")
114129
else:
115130
continue
116131
if merged_at < today_minus_seven:
@@ -137,10 +152,12 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
137152
""" Clone the circuitpython-org repo, update libraries.json, and push the updates
138153
in a commit.
139154
"""
140-
if "TRAIVS" in os.environ:
155+
if "TRAVIS" in os.environ:
141156
if not os.path.isdir(cp_org_dir):
142157
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")
144161
git.clone("-o", "adafruit", git_url, cp_org_dir)
145162
os.chdir(cp_org_dir)
146163
git.pull()
@@ -184,7 +201,9 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
184201
working_directory = os.path.abspath(os.getcwd())
185202
cp_org_dir = os.path.join(working_directory, ".cp_org")
186203

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+
]
188207

189208
output_filename = os.path.join(cp_org_dir, "_data/libraries.json")
190209
local_file_output = False
@@ -206,13 +225,21 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
206225
merged_pr_count_total = 0
207226
repos_by_error = {}
208227

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+
]
210232
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+
)
212238

213239
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
216243
repo_name = repo["name"]
217244

218245
# 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
252279
else:
253280
if error[0] not in repos_by_error:
254281
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+
)
256285

257286
# sort all of the items alphabetically
258287
sorted_new_list = {}

0 commit comments

Comments
 (0)