@@ -636,14 +636,41 @@ def validate_contents(self, repo):
636
636
if len (examples_list ) < 1 :
637
637
errors .append (ERROR_MISSING_EXAMPLE_FILES )
638
638
else :
639
- lib_name = (repo ["name" ][repo ["name" ].rfind ("CircuitPython_" )
640
- + 14 :].lower ())
639
+ def __check_lib_name (repo_name , file_name ):
640
+ """ Nested function to test example file names.
641
+ Allows examples to either match the repo name,
642
+ or have additional underscores separating the repo name.
643
+ """
644
+ file_names = set ()
645
+ file_names .add (file_name )
646
+
647
+ name_split = file_name .split ("_" )
648
+ name_rebuilt = '' .join (
649
+ (part for part in name_split if ".py" not in part )
650
+ )
651
+
652
+ if name_rebuilt : # avoid adding things like 'simpletest.py' -> ''
653
+ file_names .add (name_rebuilt )
654
+
655
+ found = False
656
+
657
+ return any (
658
+ name .startswith (repo_name ) for name in file_names
659
+ )
660
+
661
+ lib_name_start = repo ["name" ].rfind ("CircuitPython_" ) + 14
662
+ lib_name = repo ["name" ][lib_name_start :].lower ()
663
+
641
664
all_have_name = True
642
665
simpletest_exists = False
643
666
for example in examples_list :
644
- if (not example ["name" ].lower ().startswith (lib_name )
645
- and example ["name" ].endswith (".py" )):
646
- all_have_name = False
667
+ if example ["name" ].endswith (".py" ):
668
+ check_lib_name = __check_lib_name (
669
+ lib_name ,
670
+ example ["name" ].lower ()
671
+ )
672
+ if not check_lib_name :
673
+ all_have_name = False
647
674
if "simpletest" in example ["name" ].lower ():
648
675
simpletest_exists = True
649
676
if not all_have_name :
0 commit comments