Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# PyCharm
.idea
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Elia Onishchouk

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements.txt
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Introduction to Python. Hometask

RSS reader is a command-line utility which receives [RSS](wikipedia.org/wiki/RSS) URL and prints results in human-readable format.


Utility provides the following interface:
```shell
usage: rss_reader.py [-h] [--version] [--json] [--verbose] [--limit LIMIT]
[--date DATE] [--to-html TO_HTML] [--to-fb2 TO_FB2]
[--colorize]
source

Pure Python command-line RSS reader.

positional arguments:
source RSS URL

optional arguments:
-h, --help show this help message and exit
--version Prints version info
--json Prints result as JSON in stdout
--verbose Outputs verbose status messages
--limit LIMIT Limits news topics if this parameter provided
--date DATE Shows news of specific date
--to-html TO_HTML Converts news into html format and save to a specified
path
--to-fb2 TO_FB2 Converts news into fb2 format and save to a specified
path
--colorize Colorizes the cmd output
```

With the argument `--json` the program converts the news into [JSON](https://en.wikipedia.org/wiki/JSON) format.

With the argument `--limit` the program prints given number of news.

With the argument `--verbose` the program prints all logs in stdout.

With the argument `--version` the program prints in stdout it's current version and complete it's work.

With the argument `--date` the program prints or saves news of source from specific date stored if there are any.

With the argument `--to-html` the program saves news from source to the given path as a html file.

With the argument `--to-fb2` the program saves news from source to the given path as a fb2 file.

With the argument `--colorize` the program colorizes output in cmd.

# Caching

This program stores data in `"home directory"/rss_reader_cache`. In this directory images in folder `images` are stored and a `cache.json` file is located. It stores all data independent of `--date` attribute.
91 changes: 91 additions & 0 deletions json_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
type": "object",
"title": "News feed json schema",
"required": [
"Feed",
"Items"
],
"properties": {
"Feed": {
"type": "string",
"title": "Feed",
"description": "The title of the feed"
},
"Items": {
"type": "array",
"title": "News",
"items": {
"type": "object",
"title": "news",
"required": [
"title",
"description",
"link",
"pubDate",
"source"
],
"properties": {
"title": {
"type": "string",
"title": "Title",
"description": "The title of the news"
},
"description": {
"type": "string",
"title": "Description",
"description": "The description of the news"
},
"link": {
"type": "string",
"title": "Link",
"description": "The origin link of the news"
},
"pubDate": {
"type": "string",
"title": "Date",
"description": "The date this news was published"
},
"source": {
"type": "object",
"title": "Links inside the description",
"required": [
"images_links",
"href_links",
"video_links"
],
"properties": {
"images_links": {
"type": "array",
"title": "Images links",
"items": {
"type": "string",
"title": "Image link",
"description": "The source of the image"
}
},
"href_links": {
"type": "array",
"title": "Hyper references",
"items": {
"type": "string",
"title": "URL link",
"description": "The source of the hyper reference"
}
},
"video_links": {
"type": "array",
"title": "Video links",
"items": {
"type": "string",
"title": "Video link",
"description": "The source of the video"
}
}
}
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
feedparser
bs4
colorama
Empty file added rss_reader/__init__.py
Empty file.
Loading