upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-23 17:41:03 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-23 17:41:03 -0500
commit0aedf6a72aad498dda951dcc67d36fa1d449d7e5 (patch)
tree9542d7ed434f97a1e025946cd0789b5414033786 /scripts
parent71281041878937f4cb3352131c3c5f0c7e1dc43c (diff)
parent8d460a57f9b0d804fd20fc682009d2bd73f890fb (diff)
Merge remote-tracking branch 'origin/pr/8958'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check_no_game_data.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/check_no_game_data.py b/scripts/check_no_game_data.py
index bd46bfdec..a5b65e242 100644
--- a/scripts/check_no_game_data.py
+++ b/scripts/check_no_game_data.py
@@ -257,13 +257,20 @@ def tracked_files(root):
257 return [os.path.join(root, p) for p in out.decode("utf-8", "surrogateescape").split("\0") if p] 257 return [os.path.join(root, p) for p in out.decode("utf-8", "surrogateescape").split("\0") if p]
258 258
259 259
260def check(paths): 260def check(paths, unreadable=None):
261 """[(path, format)] for every regular file in `paths` that starts like game data.""" 261 """[(path, format)] for every regular file in `paths` that starts like game data.
262
263 A file that exists but cannot be opened or read is appended to `unreadable` (when given) as (path, error)."""
262 found = [] 264 found = []
263 for path in paths: 265 for path in paths:
264 if os.path.islink(path) or not os.path.isfile(path): 266 if os.path.islink(path) or not os.path.isfile(path):
265 continue # submodules, symlinks, files deleted in the working tree 267 continue # submodules, symlinks, files deleted in the working tree
266 name = classify_file(path) 268 try:
269 name = classify_file(path)
270 except OSError as e:
271 if unreadable is not None:
272 unreadable.append((path, e))
273 continue
267 if name: 274 if name:
268 found.append((path, name)) 275 found.append((path, name))
269 return found 276 return found
@@ -279,13 +286,16 @@ def display(path):
279 286
280def main(argv): 287def main(argv):
281 paths = argv or tracked_files(os.getcwd()) 288 paths = argv or tracked_files(os.getcwd())
282 found = check(paths) 289 unreadable = []
290 found = check(paths, unreadable)
283 for path, name in found: 291 for path, name in found:
284 print(f"{display(path)}: {name}") 292 print(f"{display(path)}: {name}")
293 for path, e in unreadable:
294 print(f"check_no_game_data: cannot read {display(path)}: {e.strerror or e}", file=sys.stderr)
285 if found: 295 if found:
286 print(f"{len(found)} file(s) start like game data. Remove them; see CONTRIBUTING.md.", file=sys.stderr) 296 print(f"{len(found)} file(s) start like game data. Remove them; see CONTRIBUTING.md.", file=sys.stderr)
287 return 1 297 return 1
288 return 0 298 return 2 if unreadable else 0 # 2: some files could not be checked and none of the others matched
289 299
290 300
291if __name__ == "__main__": 301if __name__ == "__main__":