-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OnlyList type, make even 1 item RSS parse as a list
- Loading branch information
Showing
6 changed files
with
200 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "rss-parser" | ||
version = "1.1.0" | ||
version = "1.1.1" | ||
description = "Typed pythonic RSS parser" | ||
authors = ["dhvcc <[email protected]>"] | ||
license = "GPL-3.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Union | ||
|
||
from pydantic.validators import list_validator | ||
|
||
|
||
class OnlyList(list): | ||
@classmethod | ||
def __get_validators__(cls): | ||
yield cls.validate | ||
yield list_validator | ||
|
||
@classmethod | ||
def validate(cls, v: Union[dict, list]): | ||
if isinstance(v, dict): | ||
return [v] | ||
return v | ||
|
||
def __repr__(self): | ||
return f"OnlyList({super().__repr__()})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
{ | ||
"channel": { | ||
"attributes": {}, | ||
"content": { | ||
"category": { | ||
"attributes": { | ||
"domain": "www.dmoz.com" | ||
}, | ||
"content": "Computers/Software/Internet/Site Management/Content Management" | ||
}, | ||
"cloud": null, | ||
"copyright": { | ||
"attributes": {}, | ||
"content": "Copyright 2004 NotePage, Inc." | ||
}, | ||
"description": { | ||
"attributes": {}, | ||
"content": "RSS is a fascinating technology. The uses for RSS are expanding daily. Take a closer look at how various industries are using the benefits of RSS in their businesses." | ||
}, | ||
"docs": { | ||
"attributes": {}, | ||
"content": "http://blogs.law.harvard.edu/tech/rss" | ||
}, | ||
"generator": { | ||
"attributes": {}, | ||
"content": "FeedForAll Beta1 (0.0.1.8)" | ||
}, | ||
"image": { | ||
"attributes": {}, | ||
"content": { | ||
"description": { | ||
"attributes": {}, | ||
"content": "FeedForAll Sample Feed" | ||
}, | ||
"height": { | ||
"attributes": {}, | ||
"content": 48 | ||
}, | ||
"link": { | ||
"attributes": {}, | ||
"content": "http://www.feedforall.com/industry-solutions.htm" | ||
}, | ||
"title": { | ||
"attributes": {}, | ||
"content": "FeedForAll Sample Feed" | ||
}, | ||
"url": { | ||
"attributes": {}, | ||
"content": "http://www.feedforall.com/ffalogo48x48.gif" | ||
}, | ||
"width": { | ||
"attributes": {}, | ||
"content": 48 | ||
} | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"attributes": {}, | ||
"content": { | ||
"author": null, | ||
"category": { | ||
"attributes": { | ||
"domain": "www.dmoz.com" | ||
}, | ||
"content": "Computers/Software/Internet/Site Management/Content Management" | ||
}, | ||
"comments": { | ||
"attributes": {}, | ||
"content": "http://www.feedforall.com/forum" | ||
}, | ||
"description": { | ||
"attributes": {}, | ||
"content": "<b>FeedForAll </b>helps Restaurant's communicate with customers. Let your customers know the latest specials or events.<br>\n<br>\nRSS feed uses include:<br>\n<i><font color=\"#FF0000\">Daily Specials <br>\nEntertainment <br>\nCalendar of Events </i></font>" | ||
}, | ||
"enclosure": null, | ||
"guid": null, | ||
"link": { | ||
"attributes": {}, | ||
"content": "http://www.feedforall.com/restaurant.htm" | ||
}, | ||
"pub_date": { | ||
"attributes": {}, | ||
"content": "Tue, 19 Oct 2004 11:09:11 -0400" | ||
}, | ||
"source": null, | ||
"title": { | ||
"attributes": {}, | ||
"content": "RSS Solutions for Restaurants" | ||
} | ||
} | ||
} | ||
], | ||
"language": { | ||
"attributes": {}, | ||
"content": "en-us" | ||
}, | ||
"last_build_date": { | ||
"attributes": {}, | ||
"content": "2004-10-19T13:39:14-04:00" | ||
}, | ||
"link": { | ||
"attributes": {}, | ||
"content": "http://www.feedforall.com/industry-solutions.htm" | ||
}, | ||
"managing_editor": { | ||
"attributes": {}, | ||
"content": "[email protected]" | ||
}, | ||
"pub_date": { | ||
"attributes": {}, | ||
"content": "2004-10-19T13:38:55-04:00" | ||
}, | ||
"rating": null, | ||
"skip_days": null, | ||
"skip_hours": null, | ||
"text_input": null, | ||
"title": { | ||
"attributes": {}, | ||
"content": "FeedForAll Sample Feed" | ||
}, | ||
"ttl": null, | ||
"web_master": { | ||
"attributes": {}, | ||
"content": "[email protected]" | ||
} | ||
} | ||
}, | ||
"version": { | ||
"attributes": {}, | ||
"content": "2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="windows-1252"?> | ||
<rss version="2.0"> | ||
<channel> | ||
<title>FeedForAll Sample Feed</title> | ||
<description>RSS is a fascinating technology. The uses for RSS are expanding daily. Take a closer look at how various industries are using the benefits of RSS in their businesses.</description> | ||
<link>http://www.feedforall.com/industry-solutions.htm</link> | ||
<category domain="www.dmoz.com">Computers/Software/Internet/Site Management/Content Management</category> | ||
<copyright>Copyright 2004 NotePage, Inc.</copyright> | ||
<docs>http://blogs.law.harvard.edu/tech/rss</docs> | ||
<language>en-us</language> | ||
<lastBuildDate>Tue, 19 Oct 2004 13:39:14 -0400</lastBuildDate> | ||
<managingEditor>[email protected]</managingEditor> | ||
<pubDate>Tue, 19 Oct 2004 13:38:55 -0400</pubDate> | ||
<webMaster>[email protected]</webMaster> | ||
<generator>FeedForAll Beta1 (0.0.1.8)</generator> | ||
<image> | ||
<url>http://www.feedforall.com/ffalogo48x48.gif</url> | ||
<title>FeedForAll Sample Feed</title> | ||
<link>http://www.feedforall.com/industry-solutions.htm</link> | ||
<description>FeedForAll Sample Feed</description> | ||
<width>48</width> | ||
<height>48</height> | ||
</image> | ||
<item> | ||
<title>RSS Solutions for Restaurants</title> | ||
<description><b>FeedForAll </b>helps Restaurant's communicate with customers. Let your customers know the latest specials or events.<br> | ||
<br> | ||
RSS feed uses include:<br> | ||
<i><font color="#FF0000">Daily Specials <br> | ||
Entertainment <br> | ||
Calendar of Events </i></font></description> | ||
<link>http://www.feedforall.com/restaurant.htm</link> | ||
<category domain="www.dmoz.com">Computers/Software/Internet/Site Management/Content Management</category> | ||
<comments>http://www.feedforall.com/forum</comments> | ||
<pubDate>Tue, 19 Oct 2004 11:09:11 -0400</pubDate> | ||
</item> | ||
</channel> | ||
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters