Skip to content

Conversation

@cpyle0819
Copy link
Contributor

This PR builds on #179 and abstracts filesystem operations in snippets.py.

Changes

  • Add fs: Fs parameter to collect_snippets, find_snippets, and collect_snippet_files functions
  • Replace direct filesystem calls with Fs interface methods:
    • Use fs.readlines() instead of open().readlines()
    • Use fs.stat() instead of path.exists()
  • Fix PathFs to use UTF-8 encoding for all file operations (read, readlines, write)
  • Add comprehensive tests using RecordFs for deterministic testing

Testing

  • All existing tests continue to pass
  • New tests cover snippet collection, file handling, and error cases
  • Tests use RecordFs for fast, deterministic filesystem simulation
  • Tests properly handle missing files and validate error reporting

Dependencies

@cpyle0819 cpyle0819 force-pushed the iteration-3-snippets branch from 4c6ce14 to ca0e870 Compare July 7, 2025 17:35
@cpyle0819 cpyle0819 self-assigned this Jul 7, 2025
@cpyle0819 cpyle0819 requested a review from DavidSouther July 7, 2025 17:39
@cpyle0819 cpyle0819 force-pushed the iteration-3-snippets branch from ca0e870 to 81a104e Compare July 7, 2025 18:27
@cpyle0819 cpyle0819 changed the base branch from iteration-2-file-utils to doc-gen-updates July 7, 2025 18:27
@cpyle0819 cpyle0819 requested a review from DavidSouther July 7, 2025 18:42
cpyle0819 added 2 commits July 7, 2025 16:35
- Add fs parameter to collect_snippets, find_snippets, and collect_snippet_files functions
- Replace direct filesystem calls with Fs interface methods:
  - Use fs.readlines() instead of open().readlines()
  - Use fs.stat() instead of path.exists()
- Fix PathFs to use UTF-8 encoding for all file operations (read, readlines, write)
- Add comprehensive tests using RecordFs for deterministic testing
- Test snippet collection, file handling, and error cases with filesystem abstraction
- Update Fs abstract method to accept encoding parameter with utf-8 default
- Update PathFs and RecordFs implementations to support encoding parameter
- Maintains backward compatibility with default utf-8 encoding
- Addresses PR feedback for Python 3.9 and earlier compatibility
@cpyle0819 cpyle0819 force-pushed the iteration-3-snippets branch from 81a104e to bfc932a Compare July 7, 2025 20:37
@cpyle0819 cpyle0819 changed the base branch from doc-gen-updates to main July 7, 2025 20:37
@cpyle0819 cpyle0819 added the Enhancement A general update to the code base. label Jul 7, 2025
@DavidSouther DavidSouther merged commit 7ac08be into main Jul 7, 2025
1 check passed
@cpyle0819 cpyle0819 deleted the iteration-3-snippets branch July 8, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement A general update to the code base.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants