MartinThoma / mpu

Martins Python Utilities - Stuff that comes in Handy
MIT License
59 stars 8 forks source link

Change method for checking against provided country (`get_currency`) #93

Open pythonreactor opened 2 years ago

pythonreactor commented 2 years ago

Problem

The current method for checking if a country exists in the given CSV file doesn't account for country names that do not have the full name as it has been set.

Example

TAIWANTAIWAN (PROVINCE OF CHINA)

Failure

>>> mpu.units.get_currency("TAIWAN")
>>> ValueError: Could not find currency 'TAIWAN'

Code Location

https://github.com/MartinThoma/mpu/blob/b0a8029ca291002a5dcb477d410eff6818d39c58/mpu/units/__init__.py#L353

pythonreactor commented 2 years ago

Proposed solution


...
is_currency = (
    True in [currency_str in r for r in row[:3]]
)
...