@@ -789,6 +789,11 @@ def validate_contents(self, repo):
789
789
]
790
790
examples_list = []
791
791
if dirs :
792
+
793
+ lib_name_start = repo ["name" ].rfind ("CircuitPython_" ) + len (
794
+ "CircuitPython_"
795
+ )
796
+ lib_name = repo ["name" ][lib_name_start :].lower ()
792
797
while dirs :
793
798
# loop through the results to ensure we capture files
794
799
# in subfolders, and add any files in the current directory
@@ -797,8 +802,19 @@ def validate_contents(self, repo):
797
802
errors .append (ERROR_UNABLE_PULL_REPO_EXAMPLES )
798
803
break
799
804
result_json = result .json ()
800
- dirs .extend ([x ["url" ] for x in result_json if x ["type" ] == "dir" ])
801
- examples_list .extend ([x for x in result_json if x ["type" ] == "file" ])
805
+ for x in result_json :
806
+ if x ["type" ] == "dir" :
807
+ if x ["name" ].startswith (lib_name ):
808
+ continue
809
+ if (
810
+ x ["name" ]
811
+ .replace ("_" , "" )
812
+ .startswith (lib_name .replace ("_" , "" ))
813
+ ):
814
+ continue
815
+ dirs .append (x ["url" ])
816
+ elif x ["type" ] == "file" :
817
+ examples_list .append (x )
802
818
803
819
if len (examples_list ) < 1 :
804
820
errors .append (ERROR_MISSING_EXAMPLE_FILES )
@@ -813,9 +829,9 @@ def __check_lib_name(
813
829
or have additional underscores separating the repo name.
814
830
"""
815
831
file_names = set ()
816
- file_names .add (file_name [ 9 :] )
832
+ file_names .add (file_name )
817
833
818
- name_split = file_name [ 9 :] .split ("_" )
834
+ name_split = file_name .split ("_" )
819
835
name_rebuilt = "" .join (
820
836
(part for part in name_split if ".py" not in part )
821
837
)
@@ -825,15 +841,12 @@ def __check_lib_name(
825
841
826
842
return any (name .startswith (repo_name ) for name in file_names )
827
843
828
- lib_name_start = repo ["name" ].rfind ("CircuitPython_" ) + 14
829
- lib_name = repo ["name" ][lib_name_start :].lower ()
830
-
831
844
all_have_name = True
832
845
simpletest_exists = False
833
846
for example in examples_list :
834
847
if example ["name" ].endswith (".py" ):
835
848
check_lib_name = __check_lib_name (
836
- lib_name , example ["path " ].lower ()
849
+ lib_name , example ["name " ].lower ()
837
850
)
838
851
if not check_lib_name :
839
852
all_have_name = False
0 commit comments