Skip to content

Commit c420a44

Browse files
committed
Changed examples dir check to be satisfied if repo name is at beginning of file or subdir containing file
1 parent 63526b0 commit c420a44

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

adabot/lib/circuitpython_library_validators.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -758,23 +758,28 @@ def validate_contents(self, repo):
758758
else:
759759

760760
def __check_lib_name(
761-
repo_name, file_name
762-
): # pylint: disable=unused-private-member
761+
repo_name,
762+
file_name,
763+
):
763764
"""Nested function to test example file names.
764765
Allows examples to either match the repo name,
765766
or have additional underscores separating the repo name.
766767
"""
767768
file_names = set()
768-
file_names.add(file_name)
769+
file_names.add(file_name[9:])
769770

770-
name_split = file_name.split("_")
771+
name_split = file_name[9:].split("_")
771772
name_rebuilt = "".join(
772773
(part for part in name_split if ".py" not in part)
773774
)
774775

775776
if name_rebuilt: # avoid adding things like 'simpletest.py' -> ''
776777
file_names.add(name_rebuilt)
777778

779+
if "/" in name_rebuilt:
780+
for i in name_rebuilt.split("/"):
781+
file_names.add(i)
782+
778783
return any(name.startswith(repo_name) for name in file_names)
779784

780785
lib_name_start = repo["name"].rfind("CircuitPython_") + 14
@@ -785,7 +790,7 @@ def __check_lib_name(
785790
for example in examples_list:
786791
if example["name"].endswith(".py"):
787792
check_lib_name = __check_lib_name(
788-
lib_name, example["name"].lower()
793+
lib_name, example["path"].lower()
789794
)
790795
if not check_lib_name:
791796
all_have_name = False

0 commit comments

Comments
 (0)