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
29 changes: 29 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
pull_request:
types: [opened, edited]

permissions:
actions: none
checks: none
contents: none
deployments: none
issues: none
packages: none
pull-requests: write
repository-projects: none
security-events: none
statuses: none

name: "Mark Final Task"
jobs:
label_regex:
runs-on: ubuntu-latest
name: Add label
steps:
- name: "Assign label to Final Task"
uses: Bhacaz/label-regex@v1
with:
field: title
regex: '(?<final_task>(F|f)(I|i)(N|n)(A|a)(L|l)[ -]*(T|t)(A|a)(S|s)(K|k)).*'
lowercase: true
token: "${{ secrets.GITHUB_TOKEN }}"
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# 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/

# pycharm
.idea

# vscode
.vscode
export_path.sh

# files convertion
parsing_news.html
*.pdf
*.jpg

# file format
*.pkl
Binary file added DejaVuSans.ttf
Binary file not shown.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.8

RUN mkdir /code

WORKDIR /code
ADD . /code
ADD requirements.txt code/requirements.txt

RUN python3.8 -m pip install --upgrade -r requirements.txt
ENV PYTHONPATH "${PATHONPATH}:/rssreader"
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements.txt
124 changes: 97 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,98 @@
# How to create a PR with a homework task

1. Create fork from the following repo: https://github.com/E-P-T/Homework. (Docs: https://docs.github.com/en/get-started/quickstart/fork-a-repo )
2. Clone your forked repo in your local folder.
3. Create separate branches for each session.Example(`session_2`, `session_3` and so on)
4. Create folder with you First and Last name in you forked repo in the created session.
5. Add your task into created folder
6. Push finished session task in the appropriate branch in accordance with written above.
You should get the structure that looks something like that

```
Branch: Session_2
DzmitryKolb
|___Task1.py
|___Task2.py
Branch: Session_3
DzmitryKolb
|___Task1.py
|___Task2.py
```

7. When you finish your work on task you should create Pull request to the appropriate branch of the main repo https://github.com/E-P-T/Homework (Docs: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
Please use the following instructions to prepare good description of the pull request:
- Pull request header should be: `Session <Number of the session> - <FirstName> <LastName>`.
Example: `Session 2 - Dzmitry Kolb`
- Pull request body: You should write here what tasks were implemented.
Example: `Finished: Task 1.2, Task 1.3, Task 1.6`
# RSS reader by Qayumjon Ergashaliyev
An RSS reader is a command-line utility that retrieves the RSS URL and prints the results in a human-readable format.


# RSS reader
RSS reader is a command-line utility that retrieves the RSS URL and prints the results in a human-readable format.

## Distribution
The program is located in module rssreader. When unpacking, it is installed in the system. After installation, to start using the program, write rss-reader to the terminal.

## Specification
The program works with command line arguments. Their description:

**usage:** docker rm my_app |& docker-compose run --name my_app app python -m rssreader \[-h] \[--version] \[--json] \[--verbose] \[--limit *LIMIT*] \[--colorize] \[--to-pdf] \[--to-html] \[--date *DATE*] source

+ Positionalarguments:
+ source => RSS URL

+ Optional arguments:
+ -h, --help => Show help message and exit. Сan be used as a single argument.
+ --version => Print version info. Сan be used as a single argument.
+ --json => Print result as JSON in stdout.
+ --verbose => Outputs verbose status messages. Use with other arguments.
+ --limit LIMIT => Limit news topics if this parameter is provided LIMIT.
+ --date DATE => Return cached news from the publication day. Format is YYYYMMDD". **Argument source has the meaning**.
+ --to-html => Convert news to html. Return file parsing_news.hmtl
+ --to-pdf => Convert news to pdf. Return parsing_news.pdf
+ --colorize => Print the result of the utility in colorized mode.

+ Additional description:
+ --limit => can be used with --json, --date, --to-pdf, --to-html.
+ --json => the description of the circuit is in the file **parsing_json_schema.json**
+ --date => can be used with --json, --limit, --to-pdf, --to-html.
+ --verbose => can be used with all agruments.
+ --colorize => use argument without --json. Because json will not be color.

For example you can use a super combination:
```bash
source --limit LIMIT --json --date Date --to-pdf --to-html
```
## Get files from container

```bash
docker cp my_app:/code/parsing_news.pdf parsing_news.pdf
docker cp my_app:/code/parsing_news.html parsing_news.html
```

## Database check

Go to your browser at. Only after starting the application at least 1 time
```bash
http://0.0.0.0:8081/db/news/news_received
```

## Testing

Test find in the most important folder.

Write before tests
```bash
pip install .
```
To test the package enter the command:
```bash
nosetests --with-coverage --cover-erase --cover-package=rssreader
```
You can test internal packages as well:
```bash
--cover-package=rssreader.parser
```

# RSS reader
RSS reader is a command-line utility that retrieves the RSS URL and prints the results in a human-readable format.

## Guide
1. Сreate docker container
```bash
docker run -it -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock python /bin/bash
```
2. Clone [repository](https://https://github.com/king9799/Homework)
```bash
git clone https://github.com/king9799/Homework.git && cd Rss-Reader
```
3. Run the docker and docker-compose installation script. If you get an error, then you have problems with the Internet. Restart the command again
```bash
chmod +x install.sh && . install.sh
```
4. To start the application write
```bash
docker rm my_app |& docker-compose run --name my_app app python -m rssreader
```
Example:
```bash
docker rm my_app |& docker-compose run --name my_app app python -m rssreader "https://news.yahoo.com/rss" --limit 1
```
5. If you want to test the code, see **manual**
6. If you go get the file pdf or html, see **manual**
7. All is ready. Read **manual**.
31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.1'

services:
mongo:
image: mongo
container_name: mongodb
hostname: mongo
ports:
- 27017:27017
app:
tty: true
container_name: rss-reader
stdin_open: true
depends_on:
- mongo
build:
context: .
dockerfile: Dockerfile
ports:
- 3000:3000
links:
- mongo:mongodb
environment:
- MONGO_URL=mongodb://mongo:27017/

mongo-express:
image: mongo-express
container_name: mongo-express
restart: always
ports:
- 8081:8081
20 changes: 20 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get -y install docker-ce

sudo curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

docker-compose up --build -d
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
feedparser==5.2.1
bs4==0.0.1
nose==1.3.7
pymongo==3.9.0
coverage==4.5.4
fpdf==1.7.2
requests==2.22.0
colored==1.4.1
Binary file added rssreader/DejaVuSans.ttf
Binary file not shown.
Empty file added rssreader/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions rssreader/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rssreader.app import rss_reader


def main():
rss_reader.main()


if __name__ == "__main__":
main()
Binary file added rssreader/app/DejaVuSans.ttf
Binary file not shown.
Empty file added rssreader/app/__init__.py
Empty file.
Loading