From 77cd39b4f6ab74b58862d04199df8f22d65ada4c Mon Sep 17 00:00:00 2001 From: Evgeniy <56510226+Evgeniy69@users.noreply.github.com> Date: Sat, 9 Nov 2019 19:39:00 +0300 Subject: [PATCH 1/2] Create README.md Add README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ffc2327 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# PythonHomework +[Introduction to Python] Homework Repository +usage: rss_reader.py [-h] [--version] [--json] [--verbose] [--limit LIMIT] + source + +Pure Python command-line RSS reader. + +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 From ca77e7c1c28ca443df658c8554a7ae582ae1743e Mon Sep 17 00:00:00 2001 From: Evgeniy69 Date: Sun, 17 Nov 2019 22:45:52 +0300 Subject: [PATCH 2/2] Initialize RSS reader --- .gitignore | 209 +++++++++++++++++++++-------------------- LICENSE | 19 ++++ README.md | 21 +---- rss_reader/__init__.py | 0 rss_reader/main.py | 28 ++++++ setup.py | 22 +++++ 6 files changed, 179 insertions(+), 120 deletions(-) create mode 100644 LICENSE create mode 100644 rss_reader/__init__.py create mode 100644 rss_reader/main.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 894a44c..82b4eda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,104 +1,105 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# 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 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ + Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# 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 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.idea \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..049963d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 The Python Packaging Authority + +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. \ No newline at end of file diff --git a/README.md b/README.md index ffc2327..ec5352e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,5 @@ -# PythonHomework -[Introduction to Python] Homework Repository -usage: rss_reader.py [-h] [--version] [--json] [--verbose] [--limit LIMIT] - source - -Pure Python command-line RSS reader. - -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 +# Example Package + +This is a simple example package. You can use +[Github-flavored Markdown](https://guides.github.com/features/mastering-markdown/) +to write your content. \ No newline at end of file diff --git a/rss_reader/__init__.py b/rss_reader/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rss_reader/main.py b/rss_reader/main.py new file mode 100644 index 0000000..f57757b --- /dev/null +++ b/rss_reader/main.py @@ -0,0 +1,28 @@ +import argparse +import urllib.request as req +from xml.dom import minidom + +parser = argparse.ArgumentParser() +parser.add_argument('--url', help='url of news source in RSS format') +args = parser.parse_args() + +with req.urlopen(args.url) as f: + content = f.read().decode("UTF-8") + contentBytes = f.read() + +rss = minidom.parseString(content) +urlTitle = rss.getElementsByTagName("channel")[0] + +print("Resource:", urlTitle.getElementsByTagName("title")[0].firstChild.data) +print("Link:", urlTitle.getElementsByTagName("link")[0].firstChild.data) +print("About:", urlTitle.getElementsByTagName("description")[0].firstChild.data) +print("\n\n") + +items = rss.getElementsByTagName("item") + +for item in items: + print("Title:", item.getElementsByTagName("title")[0].firstChild.data) + print("RSS Link:", item.getElementsByTagName("link")[0].firstChild.data) + print("Browser link:", item.getElementsByTagName("guid")[0].firstChild.data) + print("Description:", item.getElementsByTagName("description")[0].firstChild.data) + print("\n") \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b0e862a --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name="rss_reader", + version="1.0", + author="Antonyuk Evgeniy", + author_email="antoyuk.evgeniy333@gmail.com", + description="final task", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/Evgeniy69/PythonHomework", + packages=setuptools.find_packages(), + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires='>=3.7', +)