porimol / countryinfo

A python module for returning data about countries, ISO info and states/provinces within them.
MIT License
140 stars 44 forks source link

Serbia, using alternate spelling 'RS' will fail to create a valid CountryInfo object #31

Closed Lama09 closed 2 years ago

Lama09 commented 2 years ago

I try to get the info() output from Serbia while I use iso alpha2 "RS" for the country name.

CountryInfo('RS').info()

The code fails with an key error for 'rs' While 'RS' is not in the altSpellings list.

File "..\countryinfo.py", line 133, in capital _capital = self.__countries[self.__country_name]['capital'] KeyError: 'rs'

Running this code for other countries using alpha2 will work. CountryInfo('DE').info()

I'm not sure if the the constructor of CountryInfo should support the iso alpha2 name as well?

I tried than to switch to full country name and encountered a problem with country name Czechia. Your help is much appriceated.

BR Lama

dilettagoglia commented 2 years ago

This issue should be fixed when pull request #35 will be approved

porimol commented 2 years ago

@Lama09 resolved this issue.

@dilettagoglia thanks for your PR.

dilettagoglia commented 2 years ago

You're welcome. And thank you for this library, it's so helpful!

porimol commented 2 years ago

@Lama09 I'm closing this issue as its resolved!

hsks commented 1 year ago

@porimol this issue isn't resolved it seems. Fetching country info using 'RS' still gives the same error as 'RS' is not present in altSpellings.

sentinel-1 commented 8 months ago

The issue is not resolved for the standard PyPi version, i.e., if we do:

pip install countryinfo

It installs version where this issue is not fixed. Alternatively, if we do:

pip install git+https://github.com/porimol/countryinfo.git@master

Only then we install the version where it is fixed (at least currently).

Conclusion: the fixed version is not synchronized with PyPi, it needs to be updated there too.