Skip to content

Commit

Permalink
support CNY/CNH currency
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Jan 29, 2024
1 parent ea00a0b commit 57d5c3d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions investments/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Currency(Enum):
SEK = (('SEK',), '752', 'R01770')
CHF = (('CHF',), '756', 'R01775')
TRY = (('TRY',), '949', 'R01700J')
CNH = (('CNH',), '156', 'R01375') # CNY in cbr.ru

# unknown currency for cbr.ru
# CNH = (('CNH',), 'unknown', 'unknown')
# ILS = (('ILS',), '376', 'unknown')
# MXN = (('MXN',), '484', 'unknown')
# NZD = (('NZD',), '554', 'unknown')
Expand All @@ -45,12 +45,9 @@ def __init__(self, aliases: Tuple[str], iso_code: str, cbr_code: str):
@staticmethod
def parse(search: str):
try:
return [
currency_item for _, currency_item in Currency.__members__.items() # noqa: WPS609
if search in currency_item.aliases
][0]
except IndexError:
raise ValueError(search)
return [currency_item for _, currency_item in Currency.__members__.items() if search in currency_item.aliases][0]
except IndexError as err:
raise ValueError(search) from err

def __str__(self):
return str(self.aliases[0])
Expand Down

0 comments on commit 57d5c3d

Please sign in to comment.