fix country choices (#4403)

This commit is contained in:
montezdesousa
2023-03-06 13:56:57 +00:00
committed by GitHub
parent 475ebb5acd
commit 7917ce30d1
2 changed files with 14 additions and 11 deletions

View File

@@ -657,6 +657,11 @@ def valid_hour(hr: str) -> int:
return new_hr
def lower_str(string: str) -> str:
"""Convert string to lowercase."""
return string.lower()
def us_market_holidays(years) -> list:
"""Get US market holidays."""
if isinstance(years, int):

View File

@@ -15,6 +15,7 @@ from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import (
EXPORT_ONLY_FIGURES_ALLOWED,
check_positive,
lower_str,
valid_date,
)
from openbb_terminal.menu import session
@@ -79,7 +80,7 @@ class FundController(BaseController):
mt = MenuText("funds/")
mt.add_cmd("country")
mt.add_raw("\n")
mt.add_param("_country", self.country.title())
mt.add_param("_country", self.country)
mt.add_raw("\n")
mt.add_cmd("search")
mt.add_cmd("load")
@@ -181,29 +182,26 @@ class FundController(BaseController):
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="country",
description="Set a country for funds",
description="Set a country for funds.",
)
parser.add_argument(
"-n",
"--name",
type=str,
type=lower_str,
choices=self.fund_countries,
dest="name",
help="country to select",
default="",
default="united_states",
metavar="NAME",
)
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-n")
ns_parser = self.parse_known_args_and_warn(parser, other_args)
if ns_parser:
country_candidate = ns_parser.name
if country_candidate.lower() in self.fund_countries:
country_candidate = ns_parser.name.lower()
if country_candidate in self.fund_countries:
self.country = country_candidate
console.print(f"{country_candidate.title()} selected.")
else:
console.print(
f'" {country_candidate.title()} " not a valid country to select.'
)
console.print(f"'{country_candidate}' selected.")
return self.queue