Skip to content

Commit

Permalink
fix country choices (#4403)
Browse files Browse the repository at this point in the history
  • Loading branch information
montezdesousa authored Mar 6, 2023
1 parent 475ebb5 commit 7917ce3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 9 additions & 11 deletions openbb_terminal/mutual_funds/mutual_fund_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from openbb_terminal.helper_funcs import (
EXPORT_ONLY_FIGURES_ALLOWED,
check_positive,
lower_str,
valid_date,
)
from openbb_terminal.menu import session
Expand Down Expand Up @@ -79,7 +80,7 @@ def print_help(self):
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")
Expand Down Expand Up @@ -181,29 +182,26 @@ def call_country(self, other_args: List[str]):
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

Expand Down

0 comments on commit 7917ce3

Please sign in to comment.