@@ -58,27 +58,46 @@ def validate_contents(repo):
5858 return []
5959 if repo ["name" ] == "Adafruit_CircuitPython_Bundle" :
6060 return []
61+
6162 content_list = github .get ("/repos/" + repo ["full_name" ] + "/contents/" )
6263 if not content_list .ok :
6364 return ["Unable to pull repo contents" ]
65+
6466 content_list = content_list .json ()
65- files = [x ["name" ] for x in content_list ]
67+ files = [x ["name" ] for x in content_list if x ["type" ] == "file" ]
68+
6669 errors = []
6770 if ".pylintrc" not in files :
6871 errors .append ("Missing lint config" )
72+
6973 if ".travis.yml" in files :
7074 file_info = content_list [files .index (".travis.yml" )]
7175 if file_info ["size" ] > 1000 :
7276 errors .append ("Old travis config" )
7377 else :
7478 errors .append ("Missing .travis.yml" )
79+
7580 if "readthedocs.yml" in files :
7681 file_info = content_list [files .index ("readthedocs.yml" )]
7782 if file_info ["sha" ] != "f4243ad548bc5e4431f2d3c5d486f6c9c863888b" :
7883 errors .append ("Mismatched readthedocs.yml" )
7984 else :
8085 errors .append ("Missing readthedocs.yml" )
81- # TODO(tannewt): Check for an examples folder.
86+
87+ #Check for an examples folder.
88+ dirs = [x ["name" ] for x in content_list if x ["type" ] == "dir" ]
89+ if "examples" in dirs :
90+ # check for at least on .py file
91+ examples_list = github .get ("/repos/" + repo ["full_name" ] + "/contents/examples" )
92+ if not examples_list .ok :
93+ errors .append ("Unable to retrieve examples folder contents" )
94+ examples_list = examples_list .json ()
95+ examples_files = [x ["name" ] for x in examples_list if x ["type" ] == "file" and x ["name" ].endswith (".py" )]
96+ if not examples_files :
97+ errors .append ("Missing .py files in examples folder" )
98+ else :
99+ errors .append ("Missing examples folder" )
100+
82101 return errors
83102
84103full_auth = None
0 commit comments