Commit 79da235
authored
feat(py): Python feedparser compatibility improvements (P0-P1) (#39)
* feat(py): add FeedParserDict field mapping for backward compatibility
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.
* feat(py): add dict-style access for Python feedparser compatibility
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']
* feat(py): add auto-URL detection to parse() for feedparser compatibility
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
* docs: update documentation for Python feedparser compatibility
- 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
* chore: release v0.4.0
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()1 parent 6168185 commit 79da235
File tree
16 files changed
+2025
-58
lines changed- crates
- feedparser-rs-node
- feedparser-rs-py
- src
- types
- tests
16 files changed
+2025
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
10 | 23 | | |
11 | 24 | | |
12 | 25 | | |
| |||
147 | 160 | | |
148 | 161 | | |
149 | 162 | | |
150 | | - | |
| 163 | + | |
| 164 | + | |
151 | 165 | | |
152 | 166 | | |
153 | 167 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | | - | |
152 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
156 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
157 | 167 | | |
158 | 168 | | |
159 | 169 | | |
160 | | - | |
| 170 | + | |
161 | 171 | | |
162 | 172 | | |
163 | 173 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
58 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | | - | |
62 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
66 | | - | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
70 | | - | |
| 84 | + | |
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
| 88 | + | |
| 89 | + | |
74 | 90 | | |
75 | | - | |
| 91 | + | |
76 | 92 | | |
77 | | - | |
78 | 93 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
82 | 99 | | |
83 | | - | |
84 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
85 | 104 | | |
86 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
87 | 120 | | |
88 | 121 | | |
89 | 122 | | |
| |||
98 | 131 | | |
99 | 132 | | |
100 | 133 | | |
101 | | - | |
| 134 | + | |
102 | 135 | | |
103 | 136 | | |
104 | 137 | | |
| |||
132 | 165 | | |
133 | 166 | | |
134 | 167 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
139 | 172 | | |
140 | 173 | | |
141 | 174 | | |
142 | 175 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
146 | 179 | | |
147 | 180 | | |
148 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
149 | 185 | | |
150 | 186 | | |
151 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments