-
Notifications
You must be signed in to change notification settings - Fork 32
Pashkevich Anton #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Pashkevich Anton #32
Conversation
provided all details of cli interface required by technical task
final_task/rss_reader.py
Outdated
import argparse | ||
import requests | ||
|
||
parser = argparse.ArgumentParser(description='Pure Python command-line RSS reader.', prog='rss_reader') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В глобальной секции не должно быть логики. Советую перенести парсинг аргументов в отдельную функцию.
provided work logic for parsingrss feed and displaying news, --json --verbose and --limit optional arguments
cli utility 'rss_reader' was wrapped into distribution package
provided caching news via database
updated README.md in order to illustrate database structure
with open("README.md", "r") as f: | ||
long_description = f.read() | ||
|
||
setuptools.setup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласно тех заданию, должна экспортироваться утилита rss-reader
после установки пакета через pip install .
такой утилиты не появляется
# rss-reader
bash: rss-reader: command not found
|
||
return json.dumps({'news': news}, indent=2) | ||
|
||
def main(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно стоит разбить эту функцию на несколько маленьких функций
final_task/rss_reader/rss_reader.py
Outdated
""" | ||
this function prints news in stdout | ||
""" | ||
if len(news) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not news:
return None
try: | ||
logger.info(f"checking date..") | ||
if not cacher.is_valid_date(args.date): | ||
raise ValueError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
есть смысл добавить текстовое описание к каждому исключению, которое тут вызывается
final_task/rss_reader/rss_reader.py
Outdated
if args.limit: | ||
if args.limit < 1: | ||
if not args.verbose: | ||
print("error: invalid limit value") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем для печати одного и того же текста использовать и функцию print и логгер?
По идее можно обойтись только логгером
provided converting to html and pdf, fixed issues with package distribution
provided downloading font neccessary for pdf format from the Internet
format_converter.to_html(news, args.html) | ||
except (OSError, FileNotFoundError): | ||
if len(logger.handlers) == 1: | ||
logger.addHandler(logging.StreamHandler(sys.stdout)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все время говорит error: invalid directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexeiBuzuma я перепроверил, всё вроде как нормально
while text[i] != '\n': | ||
i += 1 | ||
text = text[:i] + "<br>" + text[i + 1:] | ||
i += 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень много магических чисел :)
break | ||
f.write(block) | ||
|
||
def to_pdf(news, filepath): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это достаточно большая функция. Есть смысл разделить ее на несколько маленьких
import requests | ||
from fpdf import FPDF | ||
|
||
def break_lines(text): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно я ошибаюсь, но может ли в данном случае подойти метод replace
у строки?
iterations 1-4 are completed