Skip to content

Releases: dhvcc/rss-parser

v2.1.0

26 Sep 11:25
Compare
Choose a tag to compare
  • Fixed spec regarding <category> - they're now a list of categories #50

V2

22 Feb 18:40
Compare
Choose a tag to compare
V2
  • Atom parsing support, thanks @ddkasa for #46
  • Parser renamed to RSSParser
  • Better datetime parsing, using pydantic's module

v1.2.1

24 Oct 17:38
Compare
Choose a tag to compare

v1.2.1 (+1.2.0)

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)

V1.1.0

15 Jul 00:19
Compare
Choose a tag to compare

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

31 May 23:20
5c20e0e
Compare
Choose a tag to compare
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

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)