You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`rss-parser` is typed python RSS/Atom parsing module built using [pydantic](https://github.com/pydantic/pydantic) and [xmltodict](https://github.com/martinblech/xmltodict)
18
+
`rss-parser` is a type-safe Python RSS/Atom parsing module built using [pydantic](https://github.com/pydantic/pydantic) and [xmltodict](https://github.com/martinblech/xmltodict).
19
19
20
20
## Installation
21
21
@@ -32,10 +32,10 @@ poetry build
32
32
pip install dist/*.whl
33
33
```
34
34
35
-
## V1 -> V2 migration
36
-
-`Parser` class was renamed to `RSSParser`
37
-
- Models for RSS-specific schemas were moved from `rss_parser.models` to `rss_parser.models.rss`. Generic types are not touched
38
-
- Date parsing was changed a bit, now uses pydantic's `validator` instead of `email.utils`, so the code will produce datetimes better, where it was defaulting to `str` before
35
+
## V1 -> V2 Migration
36
+
-The `Parser` class has been renamed to `RSSParser`
37
+
- Models for RSS-specific schemas have been moved from `rss_parser.models` to `rss_parser.models.rss`. Generic types remain unchanged
38
+
- Date parsing has been improved and now uses pydantic's `validator` instead of `email.utils`, producing better datetime objects where it previously defaulted to `str`
39
39
40
40
## Usage
41
41
@@ -69,15 +69,15 @@ for item in rss.channel.items:
69
69
# <p>If you could call a number and say you’re sorry
70
70
```
71
71
72
-
Here we can see that description is still somehow has <p>- this is beacause it's placed as[CDATA](https://www.w3resource.com/xml/CDATA-sections.php) like so
72
+
Here we can see that the description still contains `<p>` tags - this is because it's wrapped in[CDATA](https://www.w3resource.com/xml/CDATA-sections.php) like so:
73
73
74
74
```
75
75
<![CDATA[<p>If you could call ...</p>]]>
76
76
```
77
77
78
-
### Overriding schema
78
+
### Overriding Schema
79
79
80
-
If you want to customize the schema or provide a custom one - use `schema` keyword argument of the parser
80
+
If you want to customize the schema or provide a custom one, use the `schema` keyword argument of the parser:
81
81
82
82
```python
83
83
from rss_parser import RSSParser
@@ -105,31 +105,31 @@ print("Custom", rss.custom)
105
105
106
106
### xmltodict
107
107
108
-
This library uses [xmltodict](https://github.com/martinblech/xmltodict) to parse XML data. You can see the detailed documentation [here](https://github.com/martinblech/xmltodict#xmltodict)
108
+
This library uses [xmltodict](https://github.com/martinblech/xmltodict) to parse XML data. You can find the detailed documentation [here](https://github.com/martinblech/xmltodict#xmltodict).
109
109
110
-
The basic thing you should know is that your data is processed into dictionaries
110
+
The key thing to understand is that your data is processed into dictionaries.
111
111
112
-
For example, this data
112
+
For example, this XML:
113
113
114
114
```xml
115
115
<tag>content</tag>
116
116
```
117
117
118
-
will result in the following
118
+
will result in the following dictionary:
119
119
120
120
```python
121
121
{
122
122
"tag": "content"
123
123
}
124
124
```
125
125
126
-
*But*, when handling attributes, the content of the tag will be also a dictionary
126
+
*However*, when handling attributes, the content of the tag will also be a dictionary:
127
127
128
128
```xml
129
129
<tagattr="1"data-value="data">data</tag>
130
130
```
131
131
132
-
Turns into
132
+
This becomes:
133
133
134
134
```python
135
135
{
@@ -141,7 +141,7 @@ Turns into
141
141
}
142
142
```
143
143
144
-
Multiple children of a tag will be put into a list
144
+
Multiple children of a tag will be placed into a list:
145
145
146
146
```xml
147
147
<div>
@@ -150,7 +150,7 @@ Multiple children of a tag will be put into a list
150
150
</div>
151
151
```
152
152
153
-
Results in a list
153
+
This results in a list:
154
154
155
155
```python
156
156
[
@@ -159,8 +159,7 @@ Results in a list
159
159
]
160
160
```
161
161
162
-
If you don't want to deal with those conditions and parse something **always** as a list -
163
-
please, use `rss_parser.models.types.only_list.OnlyList` like we did in `Channel`
162
+
If you don't want to deal with these conditions and want to parse something **always** as a list, please use `rss_parser.models.types.only_list.OnlyList` like we did in `Channel`:
164
163
```python
165
164
from typing import Optional
166
165
@@ -178,11 +177,11 @@ class OptionalChannelElementsMixin(...):
0 commit comments