@@ -58,27 +58,46 @@ def validate_contents(repo):
58
58
return []
59
59
if repo ["name" ] == "Adafruit_CircuitPython_Bundle" :
60
60
return []
61
+
61
62
content_list = github .get ("/repos/" + repo ["full_name" ] + "/contents/" )
62
63
if not content_list .ok :
63
64
return ["Unable to pull repo contents" ]
65
+
64
66
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
+
66
69
errors = []
67
70
if ".pylintrc" not in files :
68
71
errors .append ("Missing lint config" )
72
+
69
73
if ".travis.yml" in files :
70
74
file_info = content_list [files .index (".travis.yml" )]
71
75
if file_info ["size" ] > 1000 :
72
76
errors .append ("Old travis config" )
73
77
else :
74
78
errors .append ("Missing .travis.yml" )
79
+
75
80
if "readthedocs.yml" in files :
76
81
file_info = content_list [files .index ("readthedocs.yml" )]
77
82
if file_info ["sha" ] != "f4243ad548bc5e4431f2d3c5d486f6c9c863888b" :
78
83
errors .append ("Mismatched readthedocs.yml" )
79
84
else :
80
85
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
+
82
101
return errors
83
102
84
103
full_auth = None
0 commit comments