Skip to content

Commit b94e933

Browse files
committed
Update README
1 parent 4a0efca commit b94e933

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

README.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rss parser
1+
# RSS Parser
22

33
[![Downloads](https://pepy.tech/badge/rss-parser)](https://pepy.tech/project/rss-parser)
44
[![Downloads](https://pepy.tech/badge/rss-parser/month)](https://pepy.tech/project/rss-parser)
@@ -15,7 +15,7 @@
1515

1616
## About
1717

18-
`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).
1919

2020
## Installation
2121

@@ -32,10 +32,10 @@ poetry build
3232
pip install dist/*.whl
3333
```
3434

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`
3939

4040
## Usage
4141

@@ -69,15 +69,15 @@ for item in rss.channel.items:
6969
# <p>If you could call a number and say you’re sorry
7070
```
7171

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:
7373

7474
```
7575
<![CDATA[<p>If you could call ...</p>]]>
7676
```
7777

78-
### Overriding schema
78+
### Overriding Schema
7979

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:
8181

8282
```python
8383
from rss_parser import RSSParser
@@ -105,31 +105,31 @@ print("Custom", rss.custom)
105105

106106
### xmltodict
107107

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).
109109

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.
111111

112-
For example, this data
112+
For example, this XML:
113113

114114
```xml
115115
<tag>content</tag>
116116
```
117117

118-
will result in the following
118+
will result in the following dictionary:
119119

120120
```python
121121
{
122122
"tag": "content"
123123
}
124124
```
125125

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:
127127

128128
```xml
129129
<tag attr="1" data-value="data">data</tag>
130130
```
131131

132-
Turns into
132+
This becomes:
133133

134134
```python
135135
{
@@ -141,7 +141,7 @@ Turns into
141141
}
142142
```
143143

144-
Multiple children of a tag will be put into a list
144+
Multiple children of a tag will be placed into a list:
145145

146146
```xml
147147
<div>
@@ -150,7 +150,7 @@ Multiple children of a tag will be put into a list
150150
</div>
151151
```
152152

153-
Results in a list
153+
This results in a list:
154154

155155
```python
156156
[
@@ -159,8 +159,7 @@ Results in a list
159159
]
160160
```
161161

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`:
164163
```python
165164
from typing import Optional
166165

@@ -178,11 +177,11 @@ class OptionalChannelElementsMixin(...):
178177
items: Optional[OnlyList[Tag[Item]]] = pydantic.Field(alias="item", default=[])
179178
```
180179

181-
### Tag field
180+
### Tag Field
182181

183-
This is a generic field that handles tags as raw data or a dictonary returned with attributes
182+
This is a generic field that handles tags as raw data or as a dictionary returned with attributes.
184183

185-
Example
184+
Example:
186185

187186
```python
188187
from rss_parser.models import XMLBaseModel
@@ -207,18 +206,17 @@ assert type(m.width), type(m.width.content) == (Tag[int], int)
207206
# The attributes are empty by default
208207
assert m.width.attributes == {} # But are populated when provided.
209208

210-
# Note that the @ symbol is trimmed from the beggining and name is convert to snake_case
209+
# Note that the @ symbol is trimmed from the beginning and the name is converted to snake_case
211210
assert m.category.attributes == {'some_attribute': 'https://example.com'}
212211
```
213212

214213
## Contributing
215214

216-
Pull requests are welcome. For major changes, please open an issue first
217-
to discuss what you would like to change.
215+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
218216

219-
Install dependencies with `poetry install` (`pip install poetry`)
217+
Install dependencies with `poetry install` (`pip install poetry`).
220218

221-
`pre-commit` usage is highly recommended. To install hooks run
219+
Using `pre-commit` is highly recommended. To install hooks, run:
222220

223221
```bash
224222
poetry run pre-commit install -t=pre-commit -t=pre-push

0 commit comments

Comments
 (0)