Rss-parser

Latest version: v2.1.0

Safety actively analyzes 688323 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

2.1.0

- Fixed spec regarding `<category>` - they're now a list of `categories` 50

2.0.0

- Atom parsing support, thanks ddkasa for 46
- `Parser` renamed to `RSSParser`
- Better `datetime` parsing, using pydantic's module

1.2.1

Changelog

- Retire support for `python 3.8`
- Remove method forwarding from `Tag` class and rename `TagRaw` -> `Tag`
- Add support for `python 3.12`
- Add backwards compatibility support for `pydantic v2` users (also `rss-parser` is now allowed to be installed with `pydantic v2`)

1.1.0

Changes:
- Stricter pydantic version pin, 42
- Added `py.typed` file to work with `mypy` 41
Other changes:
- Remove 3.12 mention in meta until this is a tested stable release
- Move `pytest` to dev dependencies

v1
V1

Complete rewrite of the library to use `xmltodict` and `pydantic`

Notable changes:
- Ditched `bs4`
- Now using `xmltodict` and `pydantic`
- Removed `limit` option
- `Parser` now uses classmethods

**I suggest reading new docs in Readme, but here's the key point apart from using pydantic**

---

Tag field

This is a generic field that handles tags as raw data or a dictonary returned with attributes

*Although this is a complex class, it forwards most of the methods to it's content attribute, so you don't notice a difference if you're only after the .content value*

Example

python
from rss_parser.models import XMLBaseModel
class Model(XMLBaseModel):
number: Tag[int]
string: Tag[str]

m = Model(
number=1,
string={'attr': '1', 'text': 'content'},
)

m.number.content == 1 Content value is an integer, as per the generic type

m.number.content + 10 == m.number + 10 But you're still able to use the Tag itself in common operators

m.number.bit_length() == 1 As it's the case for methods/attributes not found in the Tag itself

type(m.number), type(m.number.content) == (<class 'rss_parser.models.image.Tag[int]'>, <class 'int'>) types are NOT the same, however, the interfaces are very similar most of the time

m.number.attributes == {} The attributes are empty by default

m.string.attributes == {'attr': '1'} But are populated when provided. Note that the symbol is trimmed from the beggining, however, camelCase is not converted

Generic argument types are handled by pydantic - let's try to provide a string for a Tag[int] number

m = Model(number='not_a_number', string={'customAttr': 'v', 'text': 'str tag value'}) This will lead in the following traceback

Traceback (most recent call last):
...
pydantic.error_wrappers.ValidationError: 1 validation error for Model
number -> content
value is not a valid integer (type=type_error.integer)

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.