[WIP] Lastin Egor#41
[WIP] Lastin Egor#41NotEgorL wants to merge 7 commits intointroduction-to-python-bsuir-2019:masterfrom NotEgorL:FinalTask
Conversation
Created functions to find and separate feeds, using https://news.yahoo.com/rss/ like in the example. Got into grips with the argparse module on a different computer(added parts of it as a docstring to the python script).
|
|
||
| # A list to hold all headlines,links,..... | ||
|
|
||
| allheadlines=[] |
There was a problem hiding this comment.
в глобальной секции не должно быть никакой логики. нужно перенести в функции/классы.
| return links | ||
|
|
||
| #def getTimes( rs_url) | ||
| def getHeadlines( rss_url ): |
There was a problem hiding this comment.
есть много стилистических ошибок
советую посмотреть в сторону утилиты pycodestyle
|
mostly finished iteration 1 and had a go with iteration 2. Iteration one has a working rss reader with a working limit and url parameter, Cleaned up the code a bit with logic and pycodestyle |
Added the option to add to file. the file is called news.txt and takes the standard feed from feedparser. the type of it is feedparserdict. Still need to add classes and take ALL of the logic out, most of it has been done, same with pycodestyle
pep'd and docstring'd. variable name changed
added a -j for json dumping into the console. pycodestyled again
Added more arguments. Namely a -date for task 3 and a -con for converting to pdf and some other niche. The current functions are stubs for testing purposes.
| @@ -0,0 +1,8 @@ | |||
| from setuptools import setup, find_packages | |||
| setup( | |||
There was a problem hiding this comment.
после установки утилиты в чистом докер контейнере через pip install . не появляется утилита rss-reader
# rss-reader --help
bash: rss-reader: command not found| """import section""" | ||
|
|
||
| version = 0.1 | ||
| parser = argparse.ArgumentParser() |
There was a problem hiding this comment.
все еще есть много кода, который хранится в глобальной секции
нужно все перетащить как минимум в функции
| print("a") | ||
|
|
||
|
|
||
| def captureFeed(URL): |
There was a problem hiding this comment.
названия методом должны быть маленькими буквами через нижнее подчеркивание
например capture_feed
| """Outputs a json dump of feed.entries to a file that is called "news.txt".works """ | ||
| open("news.txt", "w").close() | ||
| feed = captureFeed(args.URL) | ||
| f = open("news.txt", "w+") |
There was a problem hiding this comment.
для работы с файлами имеет смысл использовать контекстные менеджеры
Created functions to find and separate feeds, using https://news.yahoo.com/rss/ like in the example.
Got into grips with the argparse module on a different computer(added parts of it as a docstring to the python script).