U
    dKE                     @   s
  U d Z ddlZddlZddlmZmZ ddlmZ erBddlm	Z	 zddl
mZ W n$ ek
rv   eddd	d
ZY nX edededededededededededededededededededededed ed!ed"ed#ed$ed%ed&ed'ed(ed)ed*ed+ed,ed-ed.ed/ed0ed1ed2ed3ed4ed5ed6ed7ed8ed9ed:ed;ed<ed=ed>ed?ed@edAedBedCedDedEedFedGedHedIedJedKedLedMedNedOedPedQedRedSedTedUedVedWedXedYedZed[ed\ed]ed^ed_ed`edaedbedceddedeedfedgedhediedjedkedledmednedoedpedqedredsedteduedvedwedxedyedzed{ed|ed}ed~edededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededededÃedăedŃedƃedǃedȃedɃedʃed˃ed̃ed̓ed΃edσedЃedуed҃edӃedԃedՃedփed׃ed؃edكedڃedۃed܃ed݃edރed߃ededededededededededededededededededededededededededededededededed edededdZded< ddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddÐdĐdŐdƐdǐdȐdɐdʐdːd̐d͐dΐdϐdАdѐdҐdӐdԐdՐd֐dאdؐdِdڐdېdܐdݐdސdߐdddddddddddddddddddddddddddddddddZdeedddZdedddZddd	d
Zedk
reeZedee d ed e  e  dS (  a  
This is a self-generating script that contains all of the iso3166-1 data.

To regenerate, a CSV file must be created that contains the latest data. Here's
how to do that:

1. Visit https://www.iso.org/obp
2. Click the "Country Codes" radio option and click the search button
3. Change the results per page to 300
4. Copy the html table and paste into Libreoffice Calc / Excel
5. Delete the French short name column
6. Delete the heading row.
7. Save as a CSV file in django_countries/iso3166-1.csv
8. Run this script from the command line
    N)TYPE_CHECKINGDict)CountriesBase)
StrPromise)gettext_lazyr   )messagereturnc                 C   s   | S )N )r   r	   r	   9/tmp/pip-unpacked-wheel-dnjn05s9/django_countries/data.py_   s    r   ZAfghanistanu   Åland IslandsZAlbaniaZAlgeriazAmerican SamoaZAndorraZAngolaZAnguillaZ
AntarcticazAntigua and BarbudaZ	ArgentinaZArmeniaZArubaZ	AustraliaZAustriaZ
AzerbaijanZBahamasZBahrainZ
BangladeshZBarbadosZBelarusZBelgiumZBelizeZBeninZBermudaZBhutanz Bolivia (Plurinational State of)z Bonaire, Sint Eustatius and SabazBosnia and HerzegovinaZBotswanazBouvet IslandZBrazilzBritish Indian Ocean TerritoryzBrunei DarussalamZBulgariazBurkina FasoZBurundiz
Cabo VerdeZCambodiaZCameroonZCanadazCayman IslandszCentral African RepublicZChadZChileZChinazChristmas IslandzCocos (Keeling) IslandsZColombiaZComorosZCongoz&Congo (the Democratic Republic of the)zCook Islandsz
Costa Ricau   Côte d'IvoireZCroatiaZCubau   CuraçaoZCyprusZCzechiaZDenmarkZDjiboutiZDominicazDominican RepublicZEcuadorZEgyptzEl SalvadorzEquatorial GuineaZEritreaZEstoniaZEswatiniZEthiopiazFalkland Islands (Malvinas)zFaroe IslandsZFijiZFinlandZFrancezFrench GuianazFrench PolynesiazFrench Southern TerritoriesZGabonZGambiaZGeorgiaZGermanyZGhanaZ	GibraltarZGreeceZ	GreenlandZGrenadaZ
GuadeloupeZGuamZ	GuatemalaZGuernseyZGuineazGuinea-BissauZGuyanaZHaitiz!Heard Island and McDonald IslandszHoly SeeZHondurasz	Hong KongZHungaryZIcelandZIndiaZ	IndonesiazIran (Islamic Republic of)ZIraqZIrelandzIsle of ManZIsraelZItalyZJamaicaZJapanZJerseyZJordanZ
KazakhstanZKenyaZKiribatiz+Korea (the Democratic People's Republic of)zKorea (the Republic of)ZKuwaitZ
Kyrgyzstanz Lao People's Democratic RepublicZLatviaZLebanonZLesothoZLiberiaZLibyaZLiechtensteinZ	LithuaniaZ
LuxembourgZMacaoZ
MadagascarZMalawiZMalaysiaZMaldivesZMaliZMaltazMarshall IslandsZ
MartiniqueZ
MauritaniaZ	MauritiusZMayotteZMexicoz Micronesia (Federated States of)zMoldova (the Republic of)ZMonacoZMongoliaZ
MontenegroZ
MontserratZMoroccoZ
MozambiqueZMyanmarZNamibiaZNauruZNepalZNetherlandszNew CaledoniazNew ZealandZ	NicaraguaZNigerZNigeriaZNiuezNorfolk IslandzNorth MacedoniazNorthern Mariana IslandsZNorwayZOmanZPakistanZPalauzPalestine, State ofZPanamazPapua New GuineaZParaguayZPeruZPhilippinesZPitcairnZPolandZPortugalzPuerto RicoZQataru   RéunionZRomaniazRussian FederationZRwandau   Saint Barthélemyz,Saint Helena, Ascension and Tristan da CunhazSaint Kitts and NeviszSaint LuciazSaint Martin (French part)zSaint Pierre and Miquelonz Saint Vincent and the GrenadinesZSamoaz
San MarinozSao Tome and PrincipezSaudi ArabiaZSenegalZSerbiaZ
SeychelleszSierra LeoneZ	SingaporezSint Maarten (Dutch part)ZSlovakiaZSloveniazSolomon IslandsZSomaliazSouth Africaz,South Georgia and the South Sandwich IslandszSouth SudanZSpainz	Sri LankaZSudanZSurinamezSvalbard and Jan MayenZSwedenZSwitzerlandzSyrian Arab RepubliczTaiwan (Province of China)Z
Tajikistanz Tanzania, the United Republic ofZThailandzTimor-LesteZTogoZTokelauZTongazTrinidad and TobagoZTunisiau   TürkiyeZTurkmenistanzTurks and Caicos IslandsZTuvaluZUgandaZUkrainezUnited Arab Emiratesz4United Kingdom of Great Britain and Northern Irelandz$United States Minor Outlying IslandszUnited States of AmericaZUruguayZ
UzbekistanZVanuatuz"Venezuela (Bolivarian Republic of)zViet NamzVirgin Islands (British)zVirgin Islands (U.S.)zWallis and FutunazWestern SaharaZYemenZZambiaZZimbabwe)ZAFZAXALZDZZASZADZAOZAIZAQZAGARZAMZAWZAUATZAZZBSZBHZBDBBZBYZBEZBZZBJZBMZBTZBOZBQZBAZBWZBVZBRIOBNZBGZBFZBI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)ZROUi  )ZRUSi  )ZRWAi  )ZBLMi  )ZSHNi  )ZKNAi  )ZLCAi  )ZMAFi  )ZSPMi  )ZVCTi  )ZWSMir  )ZSMRi  )ZSTPi  )ZSAUi  )ZSENi  )ZSRBi  )ZSYCi  )ZSLEi  )ZSGPi  )ZSXMi  )ZSVKi  )ZSVNi  )ZSLBZ   )ZSOMi  )ZZAFi  )ZSGS   )ZSSDi  )ZESPi  )ZLKA   )ZSDNi  )ZSURi  )ZSJMi  )ZSWEi  )ZCHEi  )ZSYRi  )ZTWN   )ZTJKi  )ZTZAiB  )ZTHAi  )ZTLSir  )ZTGOi   )ZTKLi  )ZTONi  )ZTTOi  )ZTUNi  )ZTURi  )ZTKMi  )ZTCAi  )ZTUVi  )ZUGAi   )ZUKRi$  )ZAREi  )ZGBRi:  )ZUMIiE  )ZUSAiH  )ZURYiZ  )ZUZBi\  )ZVUTi$  )ZVENi^  )ZVNMi  )ZVGB\   )ZVIRiR  )ZWLFil  )ZESHi  )ZYEMiw  )ZZMBi~  )ZZWEi  iso3166-1.csv)output_filenamefilenamec              
      s  ddl }ddl}ddl g }t|f}||D ]T}|d d}|dd|}|dd|}|r0|||d |d	 t|d
 f q0W 5 Q R X tt	}|
 }	W 5 Q R X  fdd}
t||
d}|d|	|j}|std| }g }|D ]4}|d dd }|d|d  d| d q|d }|d|7 }|d|d	 |j}|s^td| }g }|D ]0}|d|d  d|d	  d|d
  d qn||d 7 }|d|7 }||d	 7 }t| d}|| W 5 Q R X |S )z
    The following code can be used for self-generation of this file.

    It requires a UTF-8 CSV file containing the short ISO name and two letter
    country code as the first two columns.
    r   N*z\(the\) z
 +\[(.+)\]z (\1)         c                    s     d| d dddS )NZNFKDr   asciiignore)	normalizeencodedecode)rowunicodedatar	   r
   sort_key5  s     zself_generate.<locals>.sort_key)keyz#(.*\nCOUNTRIES = \{\n)(.*?)(\n\}.*)z4Expected a "COUNTRIES =" section in the source file!"z\"z    "z": _("z"),
z"(.*\nALT_CODES = \{\n)(.*)(\n\}.*)z5Expected an "ALT_CODES =" section in the source file!z": ("z", z),w)csvrer   openreaderrstripsubappendint__file__readsortedmatchDOTALL
ValueErrorgroupsreplacestripjoinwrite)rr   rs   r   r   	countriesZcsv_filer~   nameZsource_filecontentsr   r   bitsZcountry_listZcountry_rowcontentZ	alt_matchZalt_bitsZalt_listZoutput_filer	   r   r
   self_generate  sP    	
.
"r   rv   )	verbosityc                 C   s   i }t jt}tt j|dddD ]$}||t jt j|d  < q(t	t
t	| }|rtd t|D ]}td| dt
|  d qrn| rtd	 t	|t	t
 }d
D ]}|| q|rtd td t|D ]}td|  qd S )NZstaticflagsz*.gifr   z/The following country codes are missing a flag:  z ()z All country codes have flags. :))ZEU__ru   z7The following flags don't have a matching country code:)ospathdirnamer   globr   basenamesplitextuppersetr    printr   discard)r   filesZthis_dirr   Zflags_missingcodeZcode_missingZspecial_coder	   r	   r
   check_flags]  s&    "r   )r   c                  C   sF   t tjt t } | rBtd td t| D ]}td|  q.d S )Nru   zAThe following common names do not match an official country code:r   )r   r   ZCOMMON_NAMESr    r   r   )Zcommon_names_missingr   r	   r	   r
   check_common_namesv  s    r   __main__zWrote z countries.ru   )rq   )rv   )__doc__r   r   typingr   r   Zdjango_countries.baser   Zdjango_stubs_extr   Zdjango.utils.translationr   r   ImportErrorstrr    __annotations__Z	ALT_CODESr   r   r   r   __name__r   r   r   lenr	   r	   r	   r
   <module>   s     ~     A	
