o
    پi                     @  s   d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 e
ZdZdZdZd	Zd
Zde Ze	deeeeeeeeeeedZed Ze	deeeeef dZddddZdddZdS )zk
Extensive database of location and timezone data for nearly every airport and landing strip in the world.
    )annotationsN)Path)DictLiteral	TypedDict)   
   20260315z!Mike Borsetti <mike@borsetti.com>zCopyright 2020- Mike BorsettiMITzhttps://github.com/mborsetti/Airport)icaoiatanamecitysubdcountry	elevationlatlontzlid)ICAOIATALIDIATAMACr   r   airportsr   	code_typeCodeTypereturnDict[str, 'Airport']c                 C  s   |   }|dvrtd|  ttj}i }|djdd}tj|tj	d}|D ]}|||| < q*W d   n1 s=w   Y  |
dd |S )	a-  Loads airport data into a dict

    :param code_type: optional argument defining the key in the dictionary: 'ICAO' (default if omitted),
    'IATA' (for IATA Location Codes) or 'LID' (for U.S. FAA Location Identifiers).

    :return: a dict of dicts, each entry having the following keys:
        'icao': ICAO 4-letter Location Indicator or 4-alphanumeric FAA/TC LID
        'iata': IATA 3-letter Location Code or an empty string
        'name': Official name (diacritized latin script)
        'city': City
        'subd': Subdivision (e.g. state, province, region, etc.)
        'country': ISO 3166-1 alpha 2-code (plus 'XK' for Kosovo)
        'elevation': MSL elevation (the highest point of the landing area) in feet
        'lat': Latitude (decimal)
        'lon': Longitude (decimal)
        'tz': Timezone expressed as a tz database name (IANA-compliant) or empty string for country 'AQ' (Antarctica).
            Originally sourced from [TimeZoneDB](https://timezonedb.com)
        'lid': The FAA Location Identifier (for US country only; others is blank)
    )r   r   r   z5code_type must be one of ICAO, IATA or LID; received zairports.csvutf8encodingquotingN )lower
ValueErrorr   __file__parentjoinpathopencsv
DictReaderQUOTE_NONNUMERICpop)r   keythis_dirr   freaderrow r6   I/home/ubuntu/.local/lib/python3.10/site-packages/airportsdata/__init__.pyload)   s   
r8   dict[str, IATAMAC]c                  C  s   t d} ttj}i }d}d}d}d}|djddU}tj|tjd}|D ]A}	|		 D ]\}
}|
dkr8|}q-|
dkr?|}q-|
d	krF|}q-|
d
krL|}q-||vr^|||| | id||< q'| | || d |< q'W d   |S 1 stw   Y  |S )a  Loads IATA's Multi Airport Cities (for the "purpose of pricing, fare construction and mileage creation")
    data into a dict.

    :return: a dict of dicts, each entry having the following keys:
        'name': The IATA city name,
        'country': The IATA country code,
        'airports': a dict with the same data returned by load() for each airport that makes up the Multi Airport
           City, where the key is the airport's IATA code.
    r   r&   ziata_macs.csvr!   r"   r$   Countryz	City Codez	City NamezAirport Coder   r   N)
r8   r   r)   r*   r+   r,   r-   r.   r/   items)r   r2   	iata_macsmulti_airport_city_coder   r   airportr3   r4   row_dr1   valuer6   r6   r7   load_iata_macsL   s>   



rA   )r   )r   r   r   r    )r   r9   )__doc__
__future__r   r-   pathlibr   typingr   r   r   __package____project_name____min_python_version____version__
__author____copyright____license____url__strfloatr   r   r   r8   rA   r6   r6   r6   r7   <module>   s>   
#