@@ -140,21 +140,26 @@ def update_download_stats(bundle_path):
140
140
# pylint: disable=too-many-locals
141
141
def check_lib_links_md (bundle_path ):
142
142
"""Checks and updates the `circuitpython_library_list` Markdown document
143
- located in the Adafruit CircuitPython Bundle.
143
+ located in the Adafruit CircuitPython Bundle and Community Bundle .
144
144
"""
145
- if not "Adafruit_CircuitPython_Bundle" in bundle_path :
145
+ bundle = None
146
+ if "Adafruit_CircuitPython_Bundle" in bundle_path :
147
+ bundle = "adafruit"
148
+ listfile_name = "circuitpython_library_list.md"
149
+ elif "CircuitPython_Community_Bundle" in bundle_path :
150
+ bundle = "community"
151
+ listfile_name = "circuitpython_community_auto_library_list.md"
152
+ else :
146
153
return []
147
154
submodules_list = sorted (
148
- common_funcs .get_bundle_submodules (), key = lambda module : module [1 ]["path" ]
155
+ common_funcs .get_bundle_submodules (bundle = bundle ),
156
+ key = lambda module : module [1 ]["path" ],
149
157
)
150
- submodules_list = common_funcs .get_bundle_submodules ()
151
158
152
159
lib_count = len (submodules_list )
153
160
# used to generate commit message by comparing new libs to current list
154
161
try :
155
- with open (
156
- os .path .join (bundle_path , "circuitpython_library_list.md" ), "r"
157
- ) as lib_list :
162
+ with open (os .path .join (bundle_path , listfile_name ), "r" ) as lib_list :
158
163
read_lines = lib_list .read ().splitlines ()
159
164
except OSError :
160
165
read_lines = []
@@ -197,9 +202,7 @@ def check_lib_links_md(bundle_path):
197
202
"## Drivers:\n " ,
198
203
]
199
204
200
- with open (
201
- os .path .join (bundle_path , "circuitpython_library_list.md" ), "w"
202
- ) as md_file :
205
+ with open (os .path .join (bundle_path , listfile_name ), "w" ) as md_file :
203
206
md_file .write ("\n " .join (lib_list_header ))
204
207
for line in sorted (write_drivers ):
205
208
md_file .write (line + "\n " )
@@ -264,6 +267,16 @@ def repo_remote_url(repo_path):
264
267
265
268
def update_bundle (bundle_path ):
266
269
"""Process all libraries in the bundle, and update their version if necessary."""
270
+
271
+ if (
272
+ "Adafruit_CircuitPython_Bundle" not in bundle_path
273
+ and "CircuitPython_Community_Bundle" not in bundle_path
274
+ ):
275
+ raise ValueError (
276
+ "bundle_path must be for "
277
+ "Adafruit_CircuitPython_Bundle or CircuitPython_Community_Bundle"
278
+ )
279
+
267
280
working_directory = os .path .abspath (os .getcwd ())
268
281
os .chdir (bundle_path )
269
282
git .submodule ("foreach" , "git" , "fetch" )
@@ -307,12 +320,15 @@ def update_bundle(bundle_path):
307
320
os .chdir (working_directory )
308
321
lib_list_updates = check_lib_links_md (bundle_path )
309
322
if lib_list_updates :
323
+ if "Adafruit_CircuitPython_Bundle" in bundle_path :
324
+ listfile_name = "circuitpython_library_list.md"
325
+ bundle_url = "https://github.com/adafruit/Adafruit_CircuitPython_Bundle/"
326
+ elif "CircuitPython_Community_Bundle" in bundle_path :
327
+ listfile_name = "circuitpython_community_auto_library_list.md"
328
+ bundle_url = "https://github.com/adafruit/CircuitPython_Community_Bundle/"
310
329
updates .append (
311
330
(
312
- (
313
- "https://github.com/adafruit/Adafruit_CircuitPython_Bundle/"
314
- "circuitpython_library_list.md"
315
- ),
331
+ f"{ bundle_url } { listfile_name } " , # pylint: disable=possibly-used-before-assignment
316
332
"NA" ,
317
333
"NA" ,
318
334
" > Added the following libraries: {}" .format (
@@ -321,18 +337,6 @@ def update_bundle(bundle_path):
321
337
)
322
338
)
323
339
release_required = True
324
- if update_download_stats (bundle_path ):
325
- updates .append (
326
- (
327
- (
328
- "https://github.com/adafruit/Adafruit_CircuitPython_Bundle/"
329
- "circuitpython_library_list.md"
330
- ),
331
- "NA" ,
332
- "NA" ,
333
- " > Updated download stats for the libraries" ,
334
- )
335
- )
336
340
337
341
return updates , release_required
338
342
0 commit comments