Package: iso-codes
Version: 3.30-1
Severity: normal

I don't have access to the source documents for ISO standards, but at
<URL:http://www.iso.org/iso/country_codes/background_on_iso_3166/iso_3166-2.htm>
the information page for ISO 3166-2 says:

    Note that the characters after the separator are only unique within
    the subdivision list of one particular country. They can be (and
    have been) reused in the list of subdivision names of other
    countries e. g. ID-RI (Riau province of Indonesia) and NG-RI (Rivers
    province in Nigeria). So only a complete code element i.e. with the
    alpha-2 country code in front guarantees uniqueness.

The guarantee at the end – “a complete code element i.e. with the
alpha-2 country code in front guarantees uniqueness” – is violated by
‘/usr/share/xml/iso_3166_2.xml’.

A Python 3 session shows the discrepancy:

    >>> from xml.etree import ElementTree
    >>> iso_3166_2 = 
ElementTree.parse("/usr/share/xml/iso-codes/iso_3166_2.xml")
    >>> entry_xpath = "./iso_3166_country/iso_3166_subset/iso_3166_2_entry"
    >>> entry_codes = [node.get('code') for node in 
iso_3166_2.iterfind(entry_xpath)]

    >>> # Count of codes from every entry:
    >>> len([node.get('code') for node in iso_3166_2.iterfind(entry_xpath)])
    4691
    >>> # Count of *unique* codes from every entry:
    >>> len(set(entry_codes))
    4688

    >>> import collections
    >>> code_counts = collections.Counter(entry_codes)
    >>> print({(code, count) for (code, count) in code_counts.items() if count 
> 1})
    {('ID-MA', 2), ('CV-SL', 2), ('IE-C', 2)}

So the complete codes ‘ID-MA’, ‘CV-SL’, and ‘IE-C’ are all violating the
guarantee of uniqueness described on the ISO page.

If this is the case in upstream's data, please communicate with upstream
about the violated guarantee, and work with them to resolve it. The best
resolution would be to keep the guarantee described above (to assign a
unique complete code to every entry).

-- 
 \         “I got up the other day, and everything in my apartment has |
  `\   been stolen and replaced with an exact replica.” —Steven Wright |
_o__)                                                                  |
Ben Finney <[email protected]>



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to