Making the news command pretty with more data (#2045)

* Formatting news command

* Linting

* Linting
This commit is contained in:
northern-64bit
2022-07-06 00:31:24 +02:00
committed by GitHub
parent ac4820cdef
commit 85ce998d57
3 changed files with 53 additions and 21 deletions

View File

@@ -3,10 +3,12 @@ __docformat__ = "numpy"
import logging
import pandas as pd
from openbb_terminal.decorators import check_api_key
from openbb_terminal.common import newsapi_model
from openbb_terminal.decorators import log_start_end
from openbb_terminal.rich_config import console
from openbb_terminal.helper_funcs import print_rich_table
logger = logging.getLogger(__name__)
@@ -16,7 +18,7 @@ logger = logging.getLogger(__name__)
def display_news(
term: str,
s_from: str,
num: int = 5,
num: int = 3,
show_newest: bool = True,
sources: str = "",
):
@@ -39,13 +41,17 @@ def display_news(
if articles:
for idx, article in enumerate(articles):
console.print(
article["publishedAt"].replace("T", " ").replace("Z", ""),
" ",
article["title"],
)
# Unnecessary to use name of the source because contained in link article["source"]["name"]
console.print(article["url"], "\n")
data = [
[article["publishedAt"].replace("T", " ").replace("Z", "")],
[f"{article['description']}"],
[article["url"]],
]
table = pd.DataFrame(
data, index=["published", "content", "link"], columns=["Content"]
)
print_rich_table(table, title=article["title"])
if idx >= num - 1:
break

View File

@@ -427,7 +427,7 @@ class StocksController(StockBaseController):
)
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-l")
ns_parser = self.parse_known_args_and_warn(parser, other_args, limit=5)
ns_parser = self.parse_known_args_and_warn(parser, other_args, limit=3)
if ns_parser:
sources = ns_parser.sources
for idx, source in enumerate(sources):

View File

@@ -18,21 +18,47 @@ optional arguments:
Example:
```
2022 Feb 16, 08:33 (✨) /stocks/ $ news
256 news articles for Amazon.com,+Inc. were found since 2022-02-09
2022 Jul 04, 16:54 (🦋) /stocks/ $ news
543 news articles for Apple+Inc. were found since 2022-06-27
2022-02-16 13:06:33 ViacomCBS renames itself Paramount
https://www.livemint.com/industry/media/viacomcbs-renames-itself-paramount-11645016266083.html
2022-02-16 13:00:34 Low-code development startup Genesis raises $200M round led by Tiger Global
https://siliconangle.com/2022/02/16/low-code-development-startup-genesis-raises-200m-round-led-tiger-global/
Three ways to patch your thinking about open-source software security
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 20:11:03 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ What comes to mind when you hear “open source?” Is it a community? Better-quality software? A technology advantage │
│ that helps companies scale quickly? If so, congratulations. You understand the value developing with open-source │
│ software can bring to a business… │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://siliconangle.com/2022/07/04/three-ways-patch-thinking-open-source-software-security/ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2022-02-16 12:45:00 Ireland Prepaid Card and Digital Wallet Market Report 2022: Market is Expected to Record a CAGR of 10.9%, Increasing from US$2.74 Billion in 2022 to Reach US$4.15 Billion by 2026
https://www.prnewswire.com/news-releases/ireland-prepaid-card-and-digital-wallet-market-report-2022-market-is-expected-to-record-a-cagr-of-10-9-increasing-from-us2-74-billion-in-2022-to-reach-us4-15-billion-by-2026--301483505.html
2022-02-16 12:45:00 Ireland Prepaid Card and Digital Wallet Market Report 2022: Market is Expected to Record a CAGR of 10.9%, Increasing from US$2.74 Billion in 2022 to Reach US$4.15 Billion by 2026
https://finance.yahoo.com/news/ireland-prepaid-card-digital-wallet-124500072.html
HUUUGE, INC.: Informacja o kwartalnych przychodach ze sprzedaży
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 18:55:11 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Spis treści:1. RAPORT BIEŻĄCY2. MESSAGE (ENGLISH VERSION)3. INFORMACJE O PODMIOCIE4. PODPISY OSÓB REPREZENTUJĄCYCH │
│ SPÓŁKĘ KOMISJA NADZORU FINANSOWEGO <html> <head> </head> <body><font face='Times New... │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://www.bankier.pl/wiadomosc/HUUUGE-INC-Informacja-o-kwartalnych-przychodach-ze-sprzedazy-8369875.html │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2022-02-16 12:38:49 Futures largely flat ahead of retail sales data, Fed minutes
https://www.reuters.com/business/futures-largely-flat-ahead-retail-sales-data-fed-minutes-2022-02-16/
5 Carpooling Apps to Help You Save Money on Transportation
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 16:00:22 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ When we were kids, our parents told us not to get into cars with strangers, but that’s before we all had │
│ smartphones in our pockets and the price of gas skyrocketed. Now, if you need to get around, carpooling is a way to │
│ save at the gas pump — or the electric… │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://www.thepennyhoarder.com/save-money/carpool-apps/ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```