mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-09 10:51:57 +00:00
fix country choices (#4403)
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user