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
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
.pkl
__pycache__/
.vscode/
.idea/
.idea

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.
.log
local_settings.py
db.sqlite3


# Environments
.env
.venv
env/
venv/
77 changes: 46 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
# FinalTaskRssReader
For final task pull requests.
# **Rss-reader**
Command-line utility to receive RSS feeds, save it and convert to common formats.


## **Example**

Input:
```
python3 rss_reader.py "https://news.yahoo.com/rss" -lim 1
```
Output:
```
Title : Rep. Justin Amash turned on Trump. Will his Michigan district follow him — or turn on him?

Date : 17/11/2019

Link : https://news.yahoo.com/rep-justin-amash-turned-on-trump-will-his-michigan-district-follow-him-or-turn-on-him-110017880.html

Description : If you want to understand how impeachment is being seen by actual Americans,
there may be no better place to go than Grand Rapids, Mich. In part that’s because
the area around Grand Rapids, comprising Michigan’s Third Congressional District,
is one of only about two dozen districts in the nation to vote for Barack Obama and for Donald Trump.
```
Help:
```
positional arguments:
source RSS URL

optional arguments:
-h, --help show this help message and exit
--version Print version info
--json Print result as JSON in stdout
--verbose Outputs verbose status messages
--limit LIMIT Limit news topics if this parameter provided
--data Print news from the specified day
--html Convert news in HTML format
--pdf Condert news in PDF format
```

## Installation
```
git clone https://github.com/Clonder/FinalTaskRssParser.git
cd/final_task/rss_reader
pip install -r requirements.txt
pip install rss-reader
```


## How to create a pull request

1. Create github account. *Preferrably using email you used when registerer on this course*
2. Fork this repository. ('Fork' button at the top right of this repository page)
3. Open the page of your *new repository* that was created when you forked this repo.
4. Press button clone or download at the middle right of the page and CTRL-C the url.
5. On your machine go to the directory you want.
6. Depending on the OS you are working with, open GitBash(Windows)/Command Line or Terminal(Linux) there
7. Use command `git clone <url_you_copied>`

Congrats! You have successfully forked our repository.


## Additional project structure requirements

1. `setup.py` file for setuptools *must* be in the root of `final_task` folder. Use `setup.py` that is already there. (that means path to this file must end with `final_task/setup.py` )
2. Entry point to your application, aka its main module *must* be named as `rss_reader.py` . Use `rss_reader.py` that is already in `rss_reader` folder.
3. You should describe how does your project work, how to launch it and etc in README.md in the `final_task/README.md` file.
4. If you used any non-standart libraries they must be listed in `rss_reader/requirements.txt` file.
5. All unit test files should be in separate folder called `tests`.


## Pull request requirements(!!!)

1. When creating pull request make sure that `target branch` is `master` on OUR repo, not yours.
2. Pull request name *MUST* be in format: `YourFirstName_YourLastName_EmailYouUsedWhileRegisteringOnThisCourse`
3. Pull request which have any other name format, or invalid e-mail *will be ignored completely until you fix it*. So make sure you specified correct e-mail.
4. In pull request description specify your current iteration. You also can add there any other info you want us to know before we start code review.
5. *Pull request must NOT contain any .pyc files, any virtual environment files/folders, any IDE technical files*.



52 changes: 49 additions & 3 deletions final_task/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# Your readme here
Some text.
Checkout how to write this file using *markdown*.
# **Rss-reader**
Command-line utility to receive RSS feeds, save it and convert to common formats.


## **Example**

Input:
```
python3 rss_reader.py --lim 1 "https://news.yahoo.com/rss"
```
Output:
```
Title : Rep. Justin Amash turned on Trump. Will his Michigan district follow him — or turn on him?

Date : Sun, 17 Nov 2019 06:00:35 -0500

Link : https://news.yahoo.com/rep-justin-amash-turned-on-trump-will-his-michigan-district-follow-him-or-turn-on-him-110017880.html

Description : If you want to understand how impeachment is being seen by actual Americans,
there may be no better place to go than Grand Rapids, Mich. In part that’s because
the area around Grand Rapids, comprising Michigan’s Third Congressional District,
is one of only about two dozen districts in the nation to vote for Barack Obama and for Donald Trump.
```
Help:
```
positional arguments:
source RSS URL

optional arguments:
-h, --help show this help message and exit
--version Print version info
--json Print result as JSON in stdout
--verbose Outputs verbose status messages
--limit LIMIT Limit news topics if this parameter provided
--data Print news from the specified day
--html Convert news in HTML format
--pdf Condert news in PDF format
```

## Installation
```
pip install -r requirements.txt
pip install rss-reader
```





Binary file added final_task/rss_reader/DejaVuSans.ttf
Binary file not shown.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions final_task/rss_reader/_database/dates.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

55 changes: 55 additions & 0 deletions final_task/rss_reader/arguments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import argparse

version = '5.0'

""" Add argument commands for script """


def command_line():
parser = argparse.ArgumentParser(
description='Pure Python command-line RSS reader.',
prog='rss-reader')
Comment on lines +9 to +11

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: it is better to make this into one line, it will be still pretty readable.
Also it is better to use f"" instead of .format().


parser.add_argument(
'URL',
action="store",
help='rss url')

parser.add_argument(
'-version',
action='version',
help='info about version',
version='rss-reader {}'.format(version))

parser.add_argument(
'-json',
help='print result as json in stdout',
action='store_true')

parser.add_argument(
'-verbose',
help="print lots of debugging statements",
action="store_true")

parser.add_argument(
'-lim',
dest='limit',
type=int,
help='Limit news topics if this parameter provided')

parser.add_argument(
'-date',
type=str,
help='print news from the specified day')

parser.add_argument(
'-html',
action='store_true',
help='convert news in html format')

parser.add_argument(
'-pdf',
action='store_true',
help='convert news in pdf format')

return parser.parse_args()
10 changes: 10 additions & 0 deletions final_task/rss_reader/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import urllib.error
import urllib.request


def internet_on():
try:
urllib.request.urlopen("http://google.com", timeout=5)
return True
except (urllib.error.URLError, urllib.error.HTTPError):
return False
Loading