Skip to content

Commit 2e040b0

Browse files
committed
make starting with an unexpected prefix an exception
1 parent f3c4a98 commit 2e040b0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/shared_bindings_matrix.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def get_repository_url(directory):
239239
repository_urls[directory] = path
240240
return path
241241

242+
def remove_prefix(s, prefix):
243+
if not s.startswith(prefix):
244+
raise ValueError(f"{s=} does not start with {prefix=}")
245+
return s.removeprefix(prefix)
242246

243247
def frozen_modules_from_dirs(frozen_mpy_dirs, withurl):
244248
"""
@@ -251,7 +255,7 @@ def frozen_modules_from_dirs(frozen_mpy_dirs, withurl):
251255
"""
252256
frozen_modules = []
253257
for frozen_path in filter(lambda x: x, frozen_mpy_dirs.split(" ")):
254-
frozen_path = frozen_path.removeprefix('../../')
258+
frozen_path = remove_prefix(frozen_path, '../../')
255259
source_dir = get_circuitpython_root_dir() / frozen_path
256260
url_repository = get_repository_url(source_dir)
257261
for sub in source_dir.glob("*"):

0 commit comments

Comments
 (0)