fix busio example; update some scripts for Python 3.12

This commit is contained in:
Dan Halbert 2023-11-07 16:19:53 -05:00
parent 9e9dff4bf2
commit bfb830480c
3 changed files with 10 additions and 7 deletions

View File

@ -170,7 +170,7 @@ def build_module_map():
search_identifier = ADDITIONAL_MODULES[module] search_identifier = ADDITIONAL_MODULES[module]
else: else:
search_identifier = "CIRCUITPY_" + module.lstrip("_").upper() search_identifier = "CIRCUITPY_" + module.lstrip("_").upper()
re_pattern = f"{re.escape(search_identifier)}\s*\??=\s*(.+)" re_pattern = fr"{re.escape(search_identifier)}\s*\??=\s*(.+)"
find_config = re.findall(re_pattern, configs) find_config = re.findall(re_pattern, configs)
if not find_config: if not find_config:
continue continue
@ -242,12 +242,12 @@ def get_repository_url(directory):
with open(readme, "r") as fp: with open(readme, "r") as fp:
for line in fp.readlines(): for line in fp.readlines():
if m := re.match( if m := re.match(
"\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*", r"\s+:target:\s+(http\S+(docs.circuitpython|readthedocs)\S+)\s*",
line, line,
): ):
path = m.group(1) path = m.group(1)
break break
if m := re.search("<(http[^>]+)>", line): if m := re.search(r"<(http[^>]+)>", line):
path = m.group(1) path = m.group(1)
break break
if path is None: if path is None:

View File

@ -59,12 +59,15 @@
//| from board import * //| from board import *
//| //|
//| i2c = busio.I2C(SCL, SDA) //| i2c = busio.I2C(SCL, SDA)
//| i2c.try_lock()
//| print(i2c.scan()) //| print(i2c.scan())
//| i2c.unlock()
//| i2c.deinit() //| i2c.deinit()
//| //|
//| This example will initialize the the device, run //| This example will initialize the the device, lock the I2C bus, run
//| :py:meth:`~busio.I2C.scan` and then :py:meth:`~busio.I2C.deinit` the //| :py:meth:`~busio.I2C.scan`, unlock the bus,
//| hardware. The last step is optional because CircuitPython automatically //| and then :py:meth:`~busio.I2C.deinit` the hardware.
//| The last step is optional because CircuitPython automatically
//| resets hardware after a program finishes. //| resets hardware after a program finishes.
//| //|
//| Note that drivers will typically handle communication if provided the bus //| Note that drivers will typically handle communication if provided the bus

View File

@ -139,7 +139,7 @@ for board in build_boards:
# Flush so we will see something before 10 minutes has passed. # Flush so we will see something before 10 minutes has passed.
print(flush=True) print(flush=True)
if (not build_all) and (language is LANGUAGE_FIRST) and (exit_status is 0): if (not build_all) and (language == LANGUAGE_FIRST) and (exit_status == 0):
try: try:
with open( with open(
f"../ports/{board_info['port']}/{build_dir}/firmware.size.json", "r" f"../ports/{board_info['port']}/{build_dir}/firmware.size.json", "r"