@@ -789,6 +789,11 @@ def validate_contents(self, repo):
789789 ]
790790 examples_list = []
791791 if dirs :
792+
793+ lib_name_start = repo ["name" ].rfind ("CircuitPython_" ) + len (
794+ "CircuitPython_"
795+ )
796+ lib_name = repo ["name" ][lib_name_start :].lower ()
792797 while dirs :
793798 # loop through the results to ensure we capture files
794799 # in subfolders, and add any files in the current directory
@@ -797,8 +802,19 @@ def validate_contents(self, repo):
797802 errors .append (ERROR_UNABLE_PULL_REPO_EXAMPLES )
798803 break
799804 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 )
802818
803819 if len (examples_list ) < 1 :
804820 errors .append (ERROR_MISSING_EXAMPLE_FILES )
@@ -813,9 +829,9 @@ def __check_lib_name(
813829 or have additional underscores separating the repo name.
814830 """
815831 file_names = set ()
816- file_names .add (file_name [ 9 :] )
832+ file_names .add (file_name )
817833
818- name_split = file_name [ 9 :] .split ("_" )
834+ name_split = file_name .split ("_" )
819835 name_rebuilt = "" .join (
820836 (part for part in name_split if ".py" not in part )
821837 )
@@ -825,15 +841,12 @@ def __check_lib_name(
825841
826842 return any (name .startswith (repo_name ) for name in file_names )
827843
828- lib_name_start = repo ["name" ].rfind ("CircuitPython_" ) + 14
829- lib_name = repo ["name" ][lib_name_start :].lower ()
830-
831844 all_have_name = True
832845 simpletest_exists = False
833846 for example in examples_list :
834847 if example ["name" ].endswith (".py" ):
835848 check_lib_name = __check_lib_name (
836- lib_name , example ["path " ].lower ()
849+ lib_name , example ["name " ].lower ()
837850 )
838851 if not check_lib_name :
839852 all_have_name = False
0 commit comments