Skip to content

Fix LocalFileIdentifiableStore: count and iterate only .json store files#507

Merged
s-heppner merged 4 commits into
eclipse-basyx:developfrom
rwth-iat:fix/b10-local-file-len
May 14, 2026
Merged

Fix LocalFileIdentifiableStore: count and iterate only .json store files#507
s-heppner merged 4 commits into
eclipse-basyx:developfrom
rwth-iat:fix/b10-local-file-len

Conversation

@zrgt
Copy link
Copy Markdown
Contributor

@zrgt zrgt commented May 5, 2026

Fixes #503
Fixes #499

Changes

__len__

  • Count only .json files (case-insensitive f.lower().endswith(".json")), ignoring hidden files (.DS_Store), temp files, and subdirectories

__iter__

  • Filter out non-.json entries before yielding — stray files no longer crash the iterator
  • Replace name.rstrip(".json") with name[:-5]rstrip strips individual characters from the set {'.','j','s','o','n'}, not the literal suffix

Tests

  • test_add_and_len_consistent: verifies each add() increments len() by 1; stray file does not affect count
  • test_iter_ignores_non_json_files: verifies stray files are not yielded by iterator

Comment thread sdk/basyx/aas/backend/local_file.py Outdated
@s-heppner
Copy link
Copy Markdown
Member

Actually: Instead of adding support for .JSON, how about we ensure in a unittest that __add__ and __len__ work together?

zrgt added 2 commits May 7, 2026 18:11
Use f.lower().endswith(".json") to handle .JSON filenames.
Rename test to test_add_and_len_consistent: verify each add()
increments len() by 1, then verify stray files are not counted.

Addresses review feedback on eclipse-basyx#507
Merge __iter__ fix (filter non-.json files, use name[:-5] for suffix
removal) together with __len__ fix (case-insensitive .json filter).
Apply consistent f.lower().endswith(".json") to both methods.
Keep both test_add_and_len_consistent and test_iter_ignores_non_json_files.

Closes eclipse-basyx#499
@zrgt zrgt changed the title Fix LocalFileIdentifiableStore.__len__ to count only .json store files Fix LocalFileIdentifiableStore: count and iterate only .json store files May 7, 2026
@zrgt
Copy link
Copy Markdown
Contributor Author

zrgt commented May 7, 2026

Updated this PR to incorporate the __iter__ fix from #508 (now closed):

  • __iter__ now filters out non-.json files before yielding, preventing crashes on stray files
  • Both __len__ and __iter__ use consistent case-insensitive .json matching (f.lower().endswith(".json"))
  • rstrip(".json") replaced with name[:-5] (correct suffix removal)
  • Added test_iter_ignores_non_json_files alongside the existing test_add_and_len_consistent

@zrgt zrgt requested a review from s-heppner May 7, 2026 16:20
@s-heppner s-heppner merged commit ba01ebf into eclipse-basyx:develop May 14, 2026
15 checks passed
@s-heppner s-heppner deleted the fix/b10-local-file-len branch May 14, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants