def main(): # type: () -> None """Read the Real Python article feed""" args = [a for a in sys.argv[1:] if not a.startswith("-")] opts = [o for o in sys.argv[1:] if o.startswith("-")] # Show help message if "-h" in opts or "--help" in opts: viewer.show(__doc__) return # Should links be shown in the text show_links = "-l" in opts or "--show-links" in opts # Get URL from config file url = reader.URL # An article ID is given, show article if args: for article_id in args: article = feed.get_article(article_id, links=show_links, url=url) viewer.show(article) # No ID is given, show list of articles else: site = feed.get_site(url=url) titles = feed.get_titles(url=url) viewer.show_list(site, titles)
def main(): args = [a for a in sys.argv[1:] if not a.startswith("-")] url = reader.URL if args: for article_id in args: article = feed.get_article(article_id, url=url) viewer.show(article) else: site = feed.get_site(url=url) titles = feed.get_titles(url=url) viewer.show_list(site, titles)
def main(): """Read the Real Python article feed""" # Read URL of the Real Python feed from config file cfg = ConfigParser() cfg.read_string(resources.read_text("reader", "config.txt")) url = cfg.get("feed", "url") # If an article ID is given, show the article if len(sys.argv) > 1: article = feed.get_article(url, sys.argv[1]) viewer.show(article) # If no ID is given, show a list of all articles else: site = feed.get_site(url) titles = feed.get_titles(url) viewer.show_list(site, titles)
def main(): """Read the RealPython article feed""" # Read url of the RealPython feed from the config file cfg = ConfigParser() # initialize the ConfigParser # resources.read_text(package, resource, encoding, errors) cfg.read_string(resources.read_text("reader", "config.txt")) url = cfg.get("feed", "url") # If an article id is given, show the article if len(sys.argv) > 1: article = feed.get_article(url, sys.argv[1]) viewer.show(article) # If no id is given, so the list of all articles else: site = feed.get_site(url) titles = feed.get_titles(url) viewer.show_list(site, titles)
def test_site(local_feed): """Test that we can read the site title and link""" expected = "The latest tutorials from Setopati – Nepal's Digital Newspaper (https://setopati.net)" assert feed.get_site(url=local_feed) == expected
def test_site(local_feed): """Test that we can read the site title and link.""" expected = "Real Python (https://realpython.com/)" assert feed.get_site(url=local_feed) == expected