ó
mÜJ]c           @` s“   d  Z  d d l m Z m Z m Z m Z d d l Z e j e ƒ Z	 d d l
 Z
 d d l j j Z d d l m Z m Z d Z d „  Z e ƒ  Z d S(	   u)   This modules exposes geometry data for Unites States. It exposes a
dictionary ``data``, which is indexed by the two-tuples:

.. code-block:: python

    (state_id, county_id)

that have the following dictionaries as the associated value:

.. code-block:: python

    data[(1,1)]['name']
    data[(1,1)]['state']
    data[(1,1)]['detailed name']
    data[(1,1)]['lats']
    data[(1,1)]['lons']

Entries for ``'name'`` can have duplicates for certain states (e.g. Virginia).
The combination of ``'detailed name'`` and ``'state'`` will always be unique.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   external_patht   open_csvu   datac          C` s¿  t  d ƒ }  i  } t t d ƒ ƒ •} t | ƒ t j | d t d ƒ d t d ƒ ƒ} xZ| D]R} | \ } } } } } } } } }	 }
 } } } t j | ƒ } g  } g  } xÂ t	 | j
 d ƒ ƒ D]« \ } } | d k rø | j |  ƒ | j |  ƒ n  d	 „  | j j ƒ  Dƒ } t t g  | D]$ \ } } t  | ƒ t  | ƒ f ^ qŒ  ƒ \ } } | j | ƒ | j | ƒ qÃ Wi | d
 6|	 d 6| d 6| d 6| d 6| t |
 ƒ t | ƒ f <q_ WWd QX| S(   u   

    u   NaNu   US_Counties.csvt	   delimiteru   ,t	   quotecharu   "u)   .//outerBoundaryIs/LinearRing/coordinatesi    c         s` s"   |  ] } | j  d  ƒ d  Vq d S(   u   ,i   N(   t   split(   t   .0t   c(    (    s;   lib/python2.7/site-packages/bokeh/sampledata/us_counties.pys	   <genexpr>Y   s    u   nameu   detailed nameu   stateu   latsu   lonsN(   t   floatR   R   t   nextt   csvt   readert   strt   ett
   fromstringt	   enumeratet   findallt   appendt   textR   t   listt   zipt   extendt   int(   t   nant   datat   fR   t   rowt   namet   dummyt   statet   geometryt   det_namet   state_idt	   county_idt   xmlt   latst   lonst   it   polyt   coordst   lont   lat(    (    s;   lib/python2.7/site-packages/bokeh/sampledata/us_counties.pyt
   _read_dataE   s4    
'-"	:*(   u   data(   t   __doc__t
   __future__R    R   R   R   t   loggingt	   getLoggert   __name__t   logR   t   xml.etree.cElementTreet   etreet   cElementTreeR   t   util.sampledataR   R   t   __all__R-   R   (    (    (    s;   lib/python2.7/site-packages/bokeh/sampledata/us_counties.pyt   <module>   s   "	'