Skip to content

Commit 462006f

Browse files
authored
Merge pull request #112 from sommersoft/expand_simpletest_check
Expand Example File Checks To Include Subfolders
2 parents ee307c3 + db9522e commit 462006f

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

adabot/lib/circuitpython_library_validators.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,23 @@ def validate_contents(self, repo):
523523

524524

525525
#Check for an examples folder.
526-
dirs = [x["name"] for x in content_list if x["type"] == "dir"]
527-
if "examples" in dirs:
528-
# check for at least on .py file
529-
examples_list = github.get("/repos/"
530-
+ repo["full_name"]
531-
+ "/contents/examples")
532-
if not examples_list.ok:
533-
errors.append(ERROR_UNABLE_PULL_REPO_EXAMPLES)
534-
examples_list = examples_list.json()
526+
dirs = [
527+
x["url"] for x in content_list
528+
if (x["type"] == "dir" and x["name"] == "examples")
529+
]
530+
examples_list = []
531+
if dirs:
532+
while dirs:
533+
# loop through the results to ensure we capture files
534+
# in subfolders, and add any files in the current directory
535+
result = github.get(dirs.pop(0))
536+
if not result.ok:
537+
errors.append(ERROR_UNABLE_PULL_REPO_EXAMPLES)
538+
break
539+
result_json = result.json()
540+
dirs.extend([x["url"] for x in result_json if x["type"] == "dir"])
541+
examples_list.extend([x for x in result_json if x["type"] == "file"])
542+
535543
if len(examples_list) < 1:
536544
errors.append(ERROR_MISSING_EXAMPLE_FILES)
537545
else:

adabot/lib/common_funcs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ def list_repos():
169169
"order": "asc"}
170170
)
171171
while result.ok:
172-
links = result.headers["Link"]
173172
#repos.extend(result.json()["items"]) # uncomment and comment below, to include all forks
174173
repos.extend(repo for repo in result.json()["items"] if (repo["owner"]["login"] == "adafruit" and
175174
(repo["name"].startswith("Adafruit_CircuitPython") or repo["name"] == "circuitpython")))
176-
175+
try:
176+
links = result.headers["Link"]
177+
except KeyError:
178+
break
177179
next_url = None
178180
for link in links.split(","):
179181
link, rel = link.split(";")

0 commit comments

Comments
 (0)