Skip to content

Pivovar Sergey #46

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 43 commits into
base: master
Choose a base branch
from

Conversation

TeRRoRlsT
Copy link

Added rss_reader

Iteration 1.
Working on the model. Description shows excess HTML tags and other. Does not support setting "--json".

Iteration 1.
Working on the model. Description shows excess HTML tags and other. Does not support setting "--json".
Added:
    * File htmlparser. Contain all parsing functionality of program.
    * Added docstrings in all files.
    * Added logging. To use write '--verbose' after filename.
    * Added converting to JSON. Also now available output all news articles in JSON format.

Change:
    * Functionality of class RSSReader. All parsing work removed into htmlparser module.

Fixed all files with PEP8
    Added:
        * Added __init__.py
        * Added setup.py
        * Added README.md
        * Added package `rss-reader` with project files

    Change:
        * Project structure
        * In file `rss_reader.py` change import module `htmlparser` -> `.htmlparser`

    Fixed all files with PEP8
In file `rss_reader.py` fix local import '.htmlparser' -> 'htmlparser'
Change:
    * In file `rss_reader` change struct. Remove all parse functions to `htmlparser`.
    * In file `htmlparser` added model Article. Rewrite all method of class HTMLParser for work with model Article.
    * In all files fix docstrings with PEP8.

Fix all files with PEP8.
@AlexeiBuzuma AlexeiBuzuma added the [Deadline] Iteration 1-2 This is a marker for first and second iterations deadline. label Nov 17, 2019
Change:
    * Added in module `rss_reader` caching articles. Rewrite logging. Rewrite docstrings. Rewrite getting version of application
    * From module `htmlparser` remove model Article. Change docstrings. Change method HTMLParser.parse, now it return list of dicts of articles
    * Update version to `0.9`

Fix all files with PEP8
Added:
    * `models` with ORM models for working with db
    * `/managers/` in module with managers of relevant models
    * `controller` with storage controller for work with db

Fix all files with PEP8
… TO_HTML` + change signature of main RSSReader method. Update docstrings
…dded SamplePrintController + added JSONPrintController. All extends abstract BaseController
Changes:
    * Moved loading/saving data control logic to Article model from controller
    * Extend model Article with 2 fields `dec_description` and `dec_links`
    * Rewrite docstrings with PEP8
…g sequence + change method work with field pubDate
Fixed docstring in rss_reader

PACKAGE = 'rss-reader'

setup(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Из тех задания (вторая итерация):

This package should export CLI utility named 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.

Если запускать так, как описано в readme файле, то базовый функционал первых двух итераций работает.
Но все таки нужно добавить создание утилиты после установки пакета. (entry_points аргумент в setup функции)

:type articles: dict
"""
logging.info("Start sample output")
if (title := articles.get('title', None)) is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Первый раз вижу функционал из самого нового пайтона. Молодец :)

@TeRRoRlsT TeRRoRlsT changed the title [WIP] Pivovar Sergey Pivovar Sergey Dec 1, 2019
@@ -0,0 +1,346 @@
import datetime
Copy link
Collaborator

Choose a reason for hiding this comment

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

Падает генерация PDF для tut.by
Для ссылки из тех задания все работает корректно

# rss-reader https://news.tut.by/rss/world.rss --to-pdf /data/my_news.pdf
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/rssreader/rss_reader.py", line 129, in main
    RSSReader()(settings.source,
  File "/usr/local/lib/python3.8/site-packages/rssreader/rss_reader.py", line 80, in __call__
    OutputController.print(articles, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rssreader/output_controller.py", line 389, in print
    PDFPrintController().print_to(articles, filename=to_pdf)
  File "/usr/local/lib/python3.8/site-packages/rssreader/output_controller.py", line 183, in print_to
    writer.output(print_to)
  File "/usr/local/lib/python3.8/site-packages/fpdf/fpdf.py", line 1065, in output
    self.close()
  File "/usr/local/lib/python3.8/site-packages/fpdf/fpdf.py", line 246, in close
    self._enddoc()
  File "/usr/local/lib/python3.8/site-packages/fpdf/fpdf.py", line 1636, in _enddoc
    self._putpages()
  File "/usr/local/lib/python3.8/site-packages/fpdf/fpdf.py", line 1170, in _putpages
    p = self.pages[n].encode("latin1") if PY3K else self.pages[n] 
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 59-65: ordinal not in range(256)

@AlexeiBuzuma AlexeiBuzuma removed Hard Deadline [Deadline] Iteration 1-2 This is a marker for first and second iterations deadline. labels Dec 12, 2019
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