-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a module for translating between country names and alpha-2/3 codes #263
Add a module for translating between country names and alpha-2/3 codes #263
Conversation
@willu47, this PR implements an all-directions ISO2/ISO3-country-name mapping similar to the pycountry package, i.e., from nomenclature import countries
name = countries.get(alpha_3="...").name
alpha_3 = countries.get(name="...").alpha_3 From my point of view, it's preferable to have one versatile mapping rather than numerous distinct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Couple of comments in line but nothing major.
obj = self.data_class(**entry) | ||
self.objects.append(obj) | ||
|
||
for key, value in entry.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried fully wrapping my head around what's going on here but failed to grasp all the details.
Since it's adapted from pycountry.db.Database
I assume this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @danielhuppmann.
Good to be merged from my side.
Per a suggestion by @willu47, this PR adds a shim of the pycountry.countries feature offering a simple translation between country names (as commonly used in the modelling community) and alpha-3/alpha-2 codes including the special use of alpha-2 by the European Commission.