amckenna41 / iso3166-2

A lightweight Python package, and accompanying API, that can be used to access all of the world's most up-to-date and accurate ISO 3166-2 subdivision data, including: name, local name, code, parent code, type, latitude/longitude, flag and more.
https://iso3166-2-api-amckenna41.vercel.app/
MIT License
8 stars 0 forks source link

The ISO3166_2.__doc__ usage appears to be out of date #17

Closed charettes closed 5 months ago

charettes commented 6 months ago

The docstring mentions

from iso3166_2 import * 

#get ALL subdivision data for ALL countries
all_subdivisions = ISO3166_2()

#get ALL subdivision data for Lithuania, Namibia, Paraguay and Turkmenistan
lt_subdivisions = ISO3166_2("LT")
na_subdivisions = ISO3166_2("NA")
pry_subdivisions = ISO3166_2("PRY")
tm_subdivisions = ISO3166_2("795")

#get subdivision names, local names, types, parent codes, flag urls and lat/longitudes 
#   for GB-ANS, GB-BPL, GB-NTH, GB-WGN and GB-ZET subdivision codes for the UK
gb_subdivisions = ISO3166_2("GB")

gb_subdivisions['GB-ANS'].name
gb_subdivisions['GB-BAS'].localName
gb_subdivisions['GB-BPL'].type
gb_subdivisions['GB-NTH'].parentCode
gb_subdivisions['GB-WGN'].flagUrl
gb_subdivisions['GB-ZET'].latLng

#get list of all subdivision codes for Botswana
bw_subdivisions = ISO3166_2("BW")
bw_subdivisions.subdivision_codes()

#get list of all subdivision names for Japan
jpn_subdivisions = ISO3166_2("JPN")
jpn_subdivisions.subdivision_names()

#adding custom Belfast province to Ireland
all_subdivisions = ISO3166_2()
all_subdivisions.custom_subdivision("IE", "IE-BF", name="Belfast", local_name="Béal Feirste", type="province", lat_lng=[54.596, -5.931], parent_code=None, flag_url=None)

#searching for the Monaghan county in Ireland (IE-MN) - returning exact matching subdivision
all_subdivisions = ISO3166_2()
all_subdivisions.search("Monaghan")

#searching for any subdivisions that have "Southern" in their name, with a likeness score of 0.8
all_subdivisions = ISO3166_2()
all_subdivisions.search("Southern", any=True, likeness=0.8)

Well a few of these things simply don't work.

For example

>>> gb_subdivisions = ISO3166_2("GB")
>>> gb_subdivisions['GB-ANS'].name
*** ValueError: Invalid alpha-2 code input: GB-ANS.
amckenna41 commented 5 months ago

Hi @charettes

Apologies for the delay, I've just released version 1.6.0 of the software with a lot of updates and a few bug fixes. This issue should be resolved now. Please refer to the docs below for some updated usage examples: https://iso3166-2.readthedocs.io/en/latest/usage.html. Let me know if everything is working as expected.

Thanks!

charettes commented 4 months ago

Thank you @amckenna41, appreciated!