Skip to content

Commit fce1efc

Browse files
committed
more python3.5 compatibility fixes
1 parent 86e885c commit fce1efc

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

docs/shared_bindings_matrix.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,34 @@ def get_excluded_boards(base_json):
8585
modules = list(base_json.keys())
8686
for port in SUPPORTED_PORTS:
8787
port_dir = "ports/{}/boards".format(port)
88-
with os.scandir(port_dir) as boards:
89-
for entry in boards:
90-
if not entry.is_dir():
88+
for entry in os.scandir(port_dir):
89+
if not entry.is_dir():
90+
continue
91+
contents = ""
92+
board_dir = os.path.join(entry.path, "mpconfigboard.mk")
93+
#print(board_dir)
94+
with open(board_dir) as board:
95+
contents = board.read()
96+
for module in modules:
97+
# check if board uses `SMALL_BUILD`. if yes, and current
98+
# module is marked as `FULL_BUILD`, board is excluded
99+
small_build = re.search("CIRCUITPY_SMALL_BUILD = 1", contents)
100+
if small_build and base_json[module]["full_build"] == "1":
101+
base_json[module]["excluded"].append(entry.name)
91102
continue
92-
contents = ""
93-
board_dir = os.path.join(entry.path, "mpconfigboard.mk")
94-
#print(board_dir)
95-
with open(board_dir) as board:
96-
contents = board.read()
97-
for module in modules:
98-
# check if board uses `SMALL_BUILD`. if yes, and current
99-
# module is marked as `FULL_BUILD`, board is excluded
100-
small_build = re.search("CIRCUITPY_SMALL_BUILD = 1", contents)
101-
if small_build and base_json[module]["full_build"] == "1":
103+
104+
# check if module is specifically disabled for this board
105+
re_pattern = "CIRCUITPY_{}\s=\s(\w)".format(module.upper())
106+
find_module = re.search(re_pattern, contents)
107+
if not find_module:
108+
# check if default inclusion is off ('0'). if the board doesn't
109+
# have it explicitly enabled, its excluded.
110+
if base_json[module]["default_value"] == "0":
111+
base_json[module]["excluded"].append(entry.name)
112+
continue
113+
if (find_module.group(1) == "0" and
114+
find_module.group(1) != base_json[module]["default_value"]):
102115
base_json[module]["excluded"].append(entry.name)
103-
continue
104-
105-
# check if module is specifically disabled for this board
106-
re_pattern = "CIRCUITPY_{}\s=\s(\w)".format(module.upper())
107-
find_module = re.search(re_pattern, contents)
108-
if not find_module:
109-
# check if default inclusion is off ('0'). if the board doesn't
110-
# have it explicitly enabled, its excluded.
111-
if base_json[module]["default_value"] == "0":
112-
base_json[module]["excluded"].append(entry.name)
113-
continue
114-
if (find_module.group(1) == "0" and
115-
find_module.group(1) != base_json[module]["default_value"]):
116-
base_json[module]["excluded"].append(entry.name)
117116

118117
return base_json
119118

0 commit comments

Comments
 (0)