-
Notifications
You must be signed in to change notification settings - Fork 0
feat(py): Python feedparser compatibility improvements (P0-P1) #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Implement Phase 1 of Python feedparser compatibility improvements: - Add deprecated field aliases (description→subtitle, tagline→subtitle, modified→updated, copyright→rights, date→updated/published, url→link) - Add entry aliases (guid→id, description→summary, issued→published, modified→updated, date→updated/published) - Add container aliases (channel→feed, items→entries) - Use once_cell::Lazy<HashMap> for O(1) alias lookups - Add __getattr__ methods to PyFeedMeta, PyEntry, PyParsedFeed - Add comprehensive Python tests (19 test cases) This allows users migrating from Python feedparser to access data using familiar deprecated field names while the modern field names remain the primary API.
Implement Phase 2 of Python feedparser compatibility improvements: - Add __getitem__ method to PyParsedFeed for top-level dict access - Add __getitem__ method to PyFeedMeta for feed['field'] access - Add __getitem__ method to PyEntry for entry['field'] access - Support all modern and deprecated field names via dict syntax - Raise KeyError for unknown keys (correct dict behavior) - Add 10 comprehensive test cases for dict-style access Users can now access data using both patterns: feed['feed']['title'] # dict-style feed.feed.title # attribute-style Deprecated names also work: feed['channel']['description']
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #39 +/- ##
=======================================
Coverage 91.84% 91.84%
=======================================
Files 34 34
Lines 7758 7758
=======================================
Hits 7125 7125
Misses 633 633
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
The parse() function now automatically detects URLs (http://, https://) and fetches them when the http feature is enabled. This matches Python feedparser's behavior where parse() accepts both URLs and content. Changes: - Add optional etag, modified, user_agent params to parse() - Add optional HTTP params to parse_with_limits() - Create internal parse_internal() for shared URL/content logic - URL detection based on http:// and https:// prefix - When http feature disabled, return NotImplementedError for URLs - Update existing tests to use keyword args for limits param
- Add feedparser compatibility features to CHANGELOG [Unreleased] - Update Python README with dict-style access, field aliases, auto-URL - Update main README Python section with compatibility examples - Document supported field aliases table in Python README - Update API reference with new function signatures
Python feedparser compatibility improvements: - Field alias mappings for deprecated field names - Dict-style access on feed objects - Container aliases (channel → feed, items → entries) - Auto-URL detection in parse() function - Optional HTTP parameters for parse() and parse_with_limits()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: core
feedparser-rs-core Rust library
component: dependencies
Dependency updates or management
component: node
Node.js bindings (napi-rs)
component: python
Python bindings (PyO3)
component: tests
Test suite or test infrastructure
lang: javascript
JavaScript/TypeScript code
lang: python
Python code
lang: rust
Rust code
size: XXL
Huge PR (1000+ lines changed)
type: build
Build system, dependencies, or tooling
type: documentation
Improvements or additions to documentation
type: tooling
Development tools, CI/CD, or infrastructure
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
This PR implements Python feedparser compatibility improvements in 4 phases:
Phase 1: FeedParserDict Field Mapping ✅ (This commit)
description→subtitle,tagline→subtitle,modified→updated,copyright→rights,date→updated/published,url→linkguid→id,description→summary,issued→published,modified→updated,date→updated/publishedchannel→feed,items→entriesonce_cell::Lazy<HashMap>for O(1) alias lookups__getattr__onPyFeedMeta,PyEntry,PyParsedFeedPhases 2-4 (Coming in subsequent commits)
d['feed']['title'])Test plan