Skip to content

Add file, bytes, and directory input sources to BaseParser#192

Open
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
fahe1em1:fix/parser-input-sources
Open

Add file, bytes, and directory input sources to BaseParser#192
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
fahe1em1:fix/parser-input-sources

Conversation

@fahe1em1
Copy link

Summary

Closes #122

Adds convenience methods to BaseParser for loading data from multiple input sources. All methods delegate to the existing from_string() method, so subclass parsers (e.g., CDAParser) get these capabilities automatically.

Changes

  • from_bytes(data, encoding) — decode bytes to string, then parse
  • from_file(file_path) — read a file and parse its contents
  • from_directory(directory_path, pattern) — glob-match files in a directory and parse each one

Note

The from_url() method from the issue is deliberately omitted — it would require adding an HTTP client dependency (httpx or requests) and has security implications (SSRF) that warrant a separate discussion. Happy to add it as a follow-up if there's a preferred HTTP client.

Test plan

  • All 719 existing tests pass (uv run pytest)
  • Linter passes (uv run ruff check . --fix && uv run ruff format .)

Extends the interop engine's parser base class with convenience
methods for loading data from files, bytes, and directories.
All methods delegate to the existing from_string() method.

Closes dotimplement#122
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.

Add multiple input sources for InteropEngine parser

2 participants