Skip to content

Alex Birillo #50

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Alex Birillo #50

wants to merge 12 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 12, 2019

I am very stupid and apologize for that. I will try to correct all errors you indicated

@AlexeiBuzuma AlexeiBuzuma added the MissedPRDeadline Pull request has been opened after hard deadline. label Nov 13, 2019
@@ -0,0 +1,9 @@
import argparse

parser = argparse.ArgumentParser(description = "simple rss-reader")
Copy link
Collaborator

Choose a reason for hiding this comment

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

в глобальной секции не должно содержаться никакой логики. советую перенести парсинг аргументов в отдельную функцию

import re
import html
import json
from arg import *
Copy link
Collaborator

Choose a reason for hiding this comment

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

Очень не рекомендуется использовать импорт через *

if not args.limit:
prepared_news.append(newsdict)
with open("data.json", "w") as output:
json.dump(prepared_news, output, indent = 3, ensure_ascii = False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Разный размер табуляции

if args.version:
print("Current version: " + version.version)

if (args.verbose):
Copy link
Collaborator

Choose a reason for hiding this comment

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

советую посмотреть в сторону модуля logging

Almost all of comments have been fixed. Logs are added through logging.
Logic moved to functions.
@AlexeiBuzuma AlexeiBuzuma added the [Deadline] Iteration 1-2 This is a marker for first and second iterations deadline. label Nov 17, 2019
Implemented caching and search by date
add to README.md description related to --date
with open("README.md", "r") as f:
long_description = f.read()

setuptools.setup(
Copy link
Collaborator

Choose a reason for hiding this comment

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

при запуске в докер контейнере python:latest падает вот с такой ошибкой

# rss_reader https://news.tut.by/rss/geonews/brest.rss
Traceback (most recent call last):
  File "/usr/local/bin/rss_reader", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/rss_reader/rss_reader.py", line 24, in main
    news.caching_news(captured_news)
  File "/usr/local/lib/python3.8/site-packages/rss_reader/news.py", line 57, in caching_news
    owner_name = os.getlogin()
OSError: [Errno 6] No such device or address

@ghost ghost changed the title [WIP] Alex Birillo Alex Birillo Dec 1, 2019
except EOFError:
break

def compare_dates(newsdate):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Док стринги очень полезная вещь. Есть много функций, которые не содержат документации совсем :(

news_date = datetime.strptime(newsdate[5:len(newsdate)-13], "%d %b %Y")
news_date = str(news_date)[:10]
requared_date = arg.args.date
requared_date = requared_date[0:4] + "-" + requared_date[4:6] + "-" + requared_date[6:8]
Copy link
Collaborator

Choose a reason for hiding this comment

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

очень много магических чисел. очень сложно понять, почему они тут есть и что они значат

return news_date == requared_date

def find_news_in_cache():
isNewsFind = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Не весь код соответствует pep8

def encode_image(path):
"""Gets the path to the image and returns it into encoded string"""
with open(path, "rb") as im:
encoded_image = base64.b64encode(im.read())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Немного съехала табуляция

else:
file_path = """C:\\news.rss"""

with open(file_path, "rb") as input:
Copy link
Collaborator

Choose a reason for hiding this comment

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

имя input существует изначально в build-in (функция, которая позволяет считать ввод с клавиатуры)
лучше не переопределяь уже существующие имена, это может иногда сильно запутывать

from rss_reader.rss_fb2 import encode_image
from rss_reader import arg

class handlers(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Слабое покрытие юнит-тестами

img_file.write(img.content)
img_file.close()

def remove_image(i):
Copy link
Collaborator

Choose a reason for hiding this comment

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

что такое? image_name или image_index?
лучше не создавать имена в один символ, такой код тяжело читается

@@ -0,0 +1,20 @@

Copy link
Collaborator

Choose a reason for hiding this comment

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

Коммит сообщения должны нести информацию о том, что сделано внутри этого коммита. Например сообщение "[WIP] Alex Birillo" в целом не несет в себе никакой информацию.

from colored import fore, style


class News():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Скобки можно опустить

def write_to_json(news):
"""Creates data.json document in the directory which the application was launched"""
prepared_news = []
for i in range(len(news)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

for index, item in enumerate(news):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants