Skip to content

Commit 109ebf9

Browse files
committed
code format and licenses
1 parent 9306670 commit 109ebf9

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

tools/board_stubs/build_board_specific_stubs/board_stub_builder.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2024 Justin Myers
22
#
33
# SPDX-License-Identifier: MIT
44

@@ -19,9 +19,7 @@ def get_board_pins(pin_filename):
1919

2020
search = re.search(r"MP_ROM_QSTR\(MP_QSTR_(.*?)\), MP_ROM_PTR", line)
2121
if search is None:
22-
search = re.search(
23-
r"MP_OBJ_NEW_QSTR\(MP_QSTR_(.*?)\), MP_ROM_PTR", line
24-
)
22+
search = re.search(r"MP_OBJ_NEW_QSTR\(MP_QSTR_(.*?)\), MP_ROM_PTR", line)
2523
if search is None:
2624
continue
2725

@@ -112,7 +110,9 @@ def create_board_stubs(board_id, records, mappings, board_filename):
112110
elif extra == "epaper_display":
113111
import_name = "EPaperDisplay"
114112
class_name = f"displayio.{import_name}"
115-
member_data = f'"""Returns the `{class_name}` object for the board\'s built in display.\n'
113+
member_data = (
114+
f'"""Returns the `{class_name}` object for the board\'s built in display.\n'
115+
)
116116
member_data += f"The object created is a singleton, and uses the default parameter values for `{class_name}`.\n"
117117
member_data += '"""\n'
118118
member_data += f"{board_member}: {class_name}\n"
@@ -130,9 +130,7 @@ def create_board_stubs(board_id, records, mappings, board_filename):
130130
frozen_libraries = ", ".join(libraries["frozen_libraries"])
131131

132132
with open(board_filename, "w") as boards_file:
133-
boards_file.write(
134-
"# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries\n"
135-
)
133+
boards_file.write("# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries\n")
136134
boards_file.write("#\n")
137135
boards_file.write("# SPDX-License-Identifier: MIT\n")
138136
boards_file.write('"""\n')
@@ -244,7 +242,9 @@ def build_stubs(circuitpython_dir, circuitpython_org_dir, export_dir, version="8
244242

245243
libraries = {}
246244
if circuitpython_org_dir is None:
247-
libraries = shared_bindings_matrix.support_matrix_by_board(use_branded_name=False, withurl=False)
245+
libraries = shared_bindings_matrix.support_matrix_by_board(
246+
use_branded_name=False, withurl=False
247+
)
248248
else:
249249
with open(f"{circuitpython_org_dir}/_data/files.json") as libraries_file:
250250
libraries_list = json.load(libraries_file)
@@ -287,9 +287,7 @@ def build_stubs(circuitpython_dir, circuitpython_org_dir, export_dir, version="8
287287
board_name = board
288288
with open(f"{board_path}/mpconfigboard.h") as get_name:
289289
board_contents = get_name.read()
290-
board_name_re = re.search(
291-
r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", board_contents
292-
)
290+
board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)", board_contents)
293291
if board_name_re:
294292
board_name = board_name_re.group(1).strip('"')
295293

@@ -309,5 +307,6 @@ def build_stubs(circuitpython_dir, circuitpython_org_dir, export_dir, version="8
309307

310308
process(board_mappings, export_dir)
311309

312-
if __name__ == '__main__':
313-
build_stubs("./", None, "circuitpython-stubs/board_definitions/")
310+
311+
if __name__ == "__main__":
312+
build_stubs("./", None, "circuitpython-stubs/board_definitions/")
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
# SPDX-FileCopyrightText: 2024 Tim Cocks
2+
#
3+
# SPDX-License-Identifier: MIT
14
import sys
25
import os
36
import shutil
47

8+
59
def set_board():
610
chosen_board = sys.argv[1]
7-
#print(f"setting it {sys.argv[0]} - {sys.argv[1]}")
811
print(f"setting board: {chosen_board}")
9-
board_defs_path = os.path.sep.join(__file__.split("/")[:-2]) + f"{os.path.sep}board_definitions{os.path.sep}"
10-
board_stubs_path = os.path.sep.join(__file__.split("/")[:-2]) + f"{os.path.sep}board-stubs{os.path.sep}__init__.pyi"
12+
board_defs_path = (
13+
os.path.sep.join(__file__.split("/")[:-2]) + f"{os.path.sep}board_definitions{os.path.sep}"
14+
)
15+
board_stubs_path = (
16+
os.path.sep.join(__file__.split("/")[:-2])
17+
+ f"{os.path.sep}board-stubs{os.path.sep}__init__.pyi"
18+
)
1119

1220
if chosen_board not in os.listdir(board_defs_path):
1321
print(f"Board: '{chosen_board}' was not found")
1422
return
1523

16-
shutil.copyfile(board_defs_path + f"{os.path.sep}{chosen_board}{os.path.sep}__init__.pyi", board_stubs_path)
24+
shutil.copyfile(
25+
board_defs_path + f"{os.path.sep}{chosen_board}{os.path.sep}__init__.pyi", board_stubs_path
26+
)

0 commit comments

Comments
 (0)