@@ -140,21 +140,26 @@ def update_download_stats(bundle_path):
140140# pylint: disable=too-many-locals
141141def check_lib_links_md (bundle_path ):
142142 """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 .
144144 """
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 :
146153 return []
147154 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" ],
149157 )
150- submodules_list = common_funcs .get_bundle_submodules ()
151158
152159 lib_count = len (submodules_list )
153160 # used to generate commit message by comparing new libs to current list
154161 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 :
158163 read_lines = lib_list .read ().splitlines ()
159164 except OSError :
160165 read_lines = []
@@ -197,9 +202,7 @@ def check_lib_links_md(bundle_path):
197202 "## Drivers:\n " ,
198203 ]
199204
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 :
203206 md_file .write ("\n " .join (lib_list_header ))
204207 for line in sorted (write_drivers ):
205208 md_file .write (line + "\n " )
@@ -264,6 +267,16 @@ def repo_remote_url(repo_path):
264267
265268def update_bundle (bundle_path ):
266269 """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+
267280 working_directory = os .path .abspath (os .getcwd ())
268281 os .chdir (bundle_path )
269282 git .submodule ("foreach" , "git" , "fetch" )
@@ -307,12 +320,15 @@ def update_bundle(bundle_path):
307320 os .chdir (working_directory )
308321 lib_list_updates = check_lib_links_md (bundle_path )
309322 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/"
310329 updates .append (
311330 (
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
316332 "NA" ,
317333 "NA" ,
318334 " > Added the following libraries: {}" .format (
@@ -321,18 +337,6 @@ def update_bundle(bundle_path):
321337 )
322338 )
323339 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- )
336340
337341 return updates , release_required
338342
0 commit comments