Add file, bytes, and directory input sources to BaseParser#192
Open
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
Open
Add file, bytes, and directory input sources to BaseParser#192fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #122
Adds convenience methods to
BaseParserfor loading data from multiple input sources. All methods delegate to the existingfrom_string()method, so subclass parsers (e.g.,CDAParser) get these capabilities automatically.Changes
from_bytes(data, encoding)— decode bytes to string, then parsefrom_file(file_path)— read a file and parse its contentsfrom_directory(directory_path, pattern)— glob-match files in a directory and parse each oneNote
The
from_url()method from the issue is deliberately omitted — it would require adding an HTTP client dependency (httpxorrequests) 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
uv run pytest)uv run ruff check . --fix && uv run ruff format .)