Ë
    ûûàgün  ã                   óÜ   — d Z ddlmZ ddlmZ ddlmZmZmZmZm	Z	 ddl
mZ ddlmZ dZd	Zd
ZdZdZ G d„ d«      Z G d„ d«      Z G d„ d«      Zd„ Zdd„Zdd„Z ej2                  «        y)zÅ
    tablib.core
    ~~~~~~~~~~~

    This module implements the central Tablib objects.

    :copyright: (c) 2016 by Kenneth Reitz. 2019 Jazzband.
    :license: MIT, see LICENSE for more details.
é    )Úcopy)Ú
itemgetteré   )ÚHeadersNeededÚInvalidDatasetIndexÚInvalidDatasetTypeÚInvalidDimensionsÚUnsupportedFormat)Úregistry)Únormalize_inputÚtablibzKenneth ReitzÚMITz,Copyright 2017 Kenneth Reitz. 2019 Jazzband.Úrestructuredtextc                   óš   — e Zd ZdZddgZdd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zed„ «       Zd„ Zy)ÚRowz/Internal Row object. Mainly used for filtering.Ú_rowÚtagsc                 óD   — t        |«      | _        t        |«      | _        y ©N)Úlistr   r   ©ÚselfÚrowr   s      úI/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/tablib/core.pyÚ__init__zRow.__init__$   s   € Ü˜“IˆŒ	Ü˜“Jˆ�	ó    c                 ó(   — d„ | j                   D «       S )Nc              3   ó    K  — | ]  }|–— Œ y ­wr   © )Ú.0Úcols     r   ú	<genexpr>zRow.__iter__.<locals>.<genexpr>)   s   è ø€ Ò)˜”Ñ)ùs   ‚©r   ©r   s    r   Ú__iter__zRow.__iter__(   s   € Ù)˜tŸy™yÔ)Ð)r   c                 ó,   — t        | j                  «      S r   )Úlenr   r$   s    r   Ú__len__zRow.__len__+   s   € Ü�4—9‘9‹~Ðr   c                 ó,   — t        | j                  «      S r   )Úreprr   r$   s    r   Ú__repr__zRow.__repr__.   s   € Ü�D—I‘I‹Ðr   c                 ó    — | j                   |   S r   r#   ©r   Úis     r   Ú__getitem__zRow.__getitem__1   s   € Ø�y‰y˜‰|Ðr   c                 ó"   — || j                   |<   y r   r#   )r   r.   Úvalues      r   Ú__setitem__zRow.__setitem__4   s   € Øˆ�	‰	�!Šr   c                 ó   — | j                   |= y r   r#   r-   s     r   Ú__delitem__zRow.__delitem__7   s   € Ø�I‰I�a‰Lr   c                 ó2   — | j                   | j                  fS r   ©r   r   r$   s    r   Ú__getstate__zRow.__getstate__:   s   € Ø�y‰y˜$Ÿ)™)Ð#Ð#r   c                 ó"   — |\  | _         | _        y r   r6   )r   Ústates     r   Ú__setstate__zRow.__setstate__=   s   € Ø$ÑˆŒ	�4•9r   c                 óN   — | j                  t        | j                  «      |«       y r   )Úinsertr'   r   ©r   r1   s     r   Úrpushz	Row.rpush@   s   € Ø�‰”C˜Ÿ	™	“N EÕ*r   c                 ó(   — | j                  d|«       y )Nr   ©r<   r=   s     r   Úlpushz	Row.lpushC   s   € Ø�‰�A�uÕr   c                 ó&   — | j                  |«       y r   ©r>   r=   s     r   Úappendz
Row.appendF   s   € Ø�
‰
�5Õr   c                 ó<   — | j                   j                  ||«       y r   )r   r<   )r   Úindexr1   s      r   r<   z
Row.insertI   s   € Ø�	‰	×Ñ˜ Õ&r   c                 óz   — t        | j                  j                  «       | j                  j                  «       «      S r   )r   r   r   r   r$   s    r   r   zRow.copyL   s%   € Ü�4—9‘9—>‘>Ó# T§Y¡Y§^¡^Ó%5Ó6Ð6r   c                 ó   — || j                   v S r   r#   )r   Úitems     r   Ú__contains__zRow.__contains__O   s   € Ø�t—y‘yÐ Ð r   c                 ó,   — t        | j                  «      S )z%Tuple representation of :class:`Row`.)Útupler   r$   s    r   rL   z	Row.tupleR   s   € ô �T—Y‘YÓÐr   c                 ó,   — t        | j                  «      S )z$List representation of :class:`Row`.)r   r   r$   s    r   r   zRow.listW   s   € ô �D—I‘I‹Ðr   c                 óª   — |€yt        |t        «      r|| j                  v S t        t	        t        |«      t        | j                  «      z  «      «      S )z)Returns true if current row contains tag.F)Ú
isinstanceÚstrr   Úboolr'   Úset)r   Útags     r   Úhas_tagzRow.has_tag\   sF   € ð ˆ;ØÜ˜œSÔ!Ø˜$Ÿ)™)Ð#Ð#äœœC ›H¤s¨4¯9©9£~Ñ5Ó6Ó7Ð7r   N)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r%   r(   r+   r/   r2   r4   r7   r:   r>   rA   rD   r<   r   rJ   ÚpropertyrL   r   rT   r   r   r   r   r      s‡   „ Ù9à˜Ð €Ióò*òòòòòò$ò%ò+òòò'ò7ò!ð ñ ó ð ð ñó ðó8r   r   c                   ó‚  — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd2d„Zd3d„Zd„ Zd„ Z eee«      Zd„ Zd„ Z eee«      Zd„ Zed„ «       Zed„ «       Zd4d„Zd„ Zd5d„Zd5d„Zd5d„Zd5d„Zd5d„Zd„ Z d„ Z!d„ Z"d„ Z#d6d „Z$d4d!„Z%d4d"„Z&d7d#„Z'd7d$„Z(d4d%„Z)d&„ Z*d'„ Z+d(„ Z,d8d)„Z-d*„ Z.d+„ Z/d,„ Z0d-„ Z1d.„ Z2d/„ Z3d0„ Z4d6d1„Z5y)9ÚDatasetaÆ  The :class:`Dataset` object is the heart of Tablib. It provides all core
    functionality.

    Usually you create a :class:`Dataset` instance in your main module, and append
    rows as you collect data. ::

        data = tablib.Dataset()
        data.headers = ('name', 'age')

        for (name, age) in some_collector():
            data.append((name, age))


    Setting columns is similar. The column data length must equal the
    current height of the data and headers must be set. ::

        data = tablib.Dataset()
        data.headers = ('first_name', 'last_name')

        data.append(('John', 'Adams'))
        data.append(('George', 'Washington'))

        data.append_col((90, 67), header='age')


    You can also set rows and headers upon instantiation. This is useful if
    dealing with dozens or hundreds of :class:`Dataset` objects. ::

        headers = ('first_name', 'last_name')
        data = [('John', 'Adams'), ('George', 'Washington')]

        data = tablib.Dataset(*data, headers=headers)

    :param \*args: (optional) list of rows to populate Dataset
    :param headers: (optional) list strings for Dataset header row
    :param title: (optional) string to use as title of the Dataset


    .. admonition:: Format Attributes Definition

    If you look at the code, the various output/import formats are not
    defined within the :class:`Dataset` object. To add support for a new format, see
    :ref:`Adding New Formats <newformats>`.

    c                 óÂ   — t        d„ |D «       «      | _        d | _        g | _        g | _        i | _        |j                  d«      | _        |j                  d«      | _        y )Nc              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr   )r   )r    Úargs     r   r"   z#Dataset.__init__.<locals>.<genexpr>—   s   è ø€ Ò3 sœ#˜cŸ(Ñ3ùs   ‚ÚheadersÚtitle)	r   Ú_dataÚ_Dataset__headersÚ_separatorsÚ_formattersÚ_dynamic_columnsÚgetr`   ra   )r   ÚargsÚkwargss      r   r   zDataset.__init__–   sY   € ÜÑ3¨dÔ3Ó3ˆŒ
ØˆŒð ˆÔð ˆÔð !#ˆÔà—z‘z )Ó,ˆŒà—Z‘Z Ó(ˆ�
r   c                 ó   — | j                   S r   )Úheightr$   s    r   r(   zDataset.__len__§   s   € Ø�{‰{Ðr   c                 óX  — t        |t        «      rL|| j                  v r8| j                  j                  |«      }| j                  D �cg c]  }||   ‘Œ	 c}S t
        ‚| j                  |   }t        |t        «      r|j                  S |D �cg c]  }|j                  ‘Œ c}S c c}w c c}w r   )rO   rP   r`   rF   rb   ÚKeyErrorr   rL   )r   ÚkeyÚposr   Ú_resultsÚresults         r   r/   zDataset.__getitem__ª   sŠ   € Ü�cœ3ÔØ�d—l‘lÑ"Ø—l‘l×(Ñ(¨Ó-�Ø,0¯J©JÖ7 S˜˜C›Ò7Ð7ä�à—z‘z #‘ˆHÜ˜(¤CÔ(Ø—~‘~Ð%à3;Ö<¨˜Ÿ›Ò<Ð<ùò 8ùò =s   ÁB"ÂB'c                 óV   — | j                  |«       t        |«      | j                  |<   y r   )Ú	_validater   rb   )r   rn   r1   s      r   r2   zDataset.__setitem__¸   s   € Ø�‰�uÔÜ˜e›*ˆ�
‰
�3Šr   c                 óL  — t        |t        «      r‡|| j                  v rs| j                  j                  |«      }| j                  |= || j                  v r| j                  |= t        | j                  «      D ]  \  }}||= || j                  |<   Œ y t        ‚| j                  |= y r   )rO   rP   r`   rF   rf   Ú	enumeraterb   rm   )r   rn   ro   r.   r   s        r   r4   zDataset.__delitem__¼   s–   € Ü�cœ3Ôà�d—l‘lÑ"à—l‘l×(Ñ(¨Ó-�Ø—L‘L Ð%Ø˜$×/Ñ/Ñ/Ø×-Ñ-¨cÐ2ä'¨¯
©
Ó3ò (‘F�A�sà˜C˜Ø$'�D—J‘J˜q’Mñ(ô
 �à—
‘
˜3‘r   c                 ó\   — 	 d| j                   j                  «       z  S # t        $ r Y yw xY w)Nz<%s dataset>z<dataset object>©ra   ÚlowerÚAttributeErrorr$   s    r   r+   zDataset.__repr__Ï   s1   € ð	&Ø! T§Z¡Z×%5Ñ%5Ó%7Ñ8Ð8øÜò 	&Ù%ð	&úó   ‚ Ÿ	+ª+c           	      óD  ‡— g }| j                   r2|j                  | j                   D �cg c]  }t        |«      ‘Œ c}«       |j                  d„ | j                  D «       «       |D �cg c]  }t        t        t        |«      «      ‘Œ }}t        t        t        t        |Ž «      «      }| j                   r#|j                  d|D �cg c]  }d|z  ‘Œ	 c}«       dj                  d„ t        |«      D «       «      Šdj                  ˆfd„|D «       «      S c c}w c c}w c c}w )Nc              3   óN   K  — | ]  }t        t        t        |«      «      –— Œ y ­wr   )r   ÚmaprP   )r    r   s     r   r"   z"Dataset.__str__.<locals>.<genexpr>Ý   s   è ø€ Ò@¨c”dœ3œs C›=×)Ñ@ùs   ‚#%r   ú-ú|c              3   ó&   K  — | ]	  }d |z  –— Œ y­w)z{%s:%s}Nr   )r    rI   s     r   r"   z"Dataset.__str__.<locals>.<genexpr>æ   s   è ø€ Ò T°d ¨TÕ!1Ñ Tùs   ‚ú
c              3   ó<   •K  — | ]  } ‰j                   |Ž –— Œ y ­wr   )Úformat)r    r   Úformat_strings     €r   r"   z"Dataset.__str__.<locals>.<genexpr>è   s   øè ø€ ÒF¸Ð-˜×-Ñ-¨sÔ3ÑFùs   ƒ)rc   rD   rP   Úextendrb   r   r}   r'   ÚmaxÚzipr<   Újoinru   )r   rq   Úhr   ÚlensÚ
field_lensÚlengthr„   s          @r   Ú__str__zDataset.__str__Õ   sß   ø€ Øˆð �>Š>Ø�M‰M¨4¯>©>Ö: aœ3˜q�6Ò:Ô;ð 	�‰Ñ@°T·Z±ZÔ@Ô@à/5Ö6¨””Sœ˜c“]Õ#Ð6ˆÐ6Üœ#œc¤3¨ :Ó.Ó/ˆ
ð �>Š>Ø�M‰M˜!¸ÖD¨v˜c F›lÒDÔEàŸ™Ñ T¼iÈ
Ó>SÔ TÓTˆà�y‰yÓF¸vÔFÓFÐFùò ;ùò
 7ùò
 Es   ©DÁ( DÃD
c                 óN   —  t        j                  |«      j                  | fi |¤ŽS r   )r   Ú
get_formatÚ
export_set)r   Úfmt_keyri   s      r   Ú_get_in_formatzDataset._get_in_formatî   s%   € Ø6Œx×"Ñ" 7Ó+×6Ñ6°tÑF¸vÑFÐFr   c                 óf   — t        |«      } t        j                  |«      j                  | |fi |¤ŽS r   )r   r   r�   Ú
import_set)r   r‘   Ú	in_streamri   s       r   Ú_set_in_formatzDataset._set_in_formatñ   s1   € Ü# IÓ.ˆ	Ø6Œx×"Ñ" 7Ó+×6Ñ6°t¸YÑQÈ&ÑQÐQr   Nc                 ó€  ‡ — |rX‰ j                   rIt        |«      ‰ j                   k(  xs. t        |«      ‰ j                   t        ‰ j                  «      z
  k(  }n[d}nX|r8t        |«      dk  rd}nE‰ j                  rt        |«      ‰ j                  k(  nd}nt	        ˆ fd„‰ j
                  D «       «      }|ry|st        ‚y)z>Assures size of every row in dataset is of proper proportions.Tr   c              3   óN   •K  — | ]  }t        |«      ‰j                  k(  –— Œ y ­wr   )r'   Úwidth)r    Úxr   s     €r   r"   z$Dataset._validate.<locals>.<genexpr>  s   øè ø€ ÒD°Aœ3˜q›6 T§Z¡ZÕ/ÑDùs   ƒ"%F)r™   r'   rf   rk   Úallrb   r	   )r   r   r!   ÚsafetyÚis_valids   `    r   rs   zDataset._validateõ   s¢   ø€ áØ�zŠzä˜“H §
¡
Ñ*ò JÜ˜“H §¡¬c°$×2GÑ2GÓ.HÑ!HÑIñ ð
  ‘ÙÜ�3‹x˜!Š|Ø‘à8<¿ºœC ›H¨¯©Ò3È‘äÓD¸¿¹ÔDÓDˆHáØáÜ'Ð'Ør   c                 óx  ‡ — t        ‰ j                  «      }ˆ fd„}‰ j                  rn|r=|D �cg c]0  }t        t        t	        ‰ j                   ||«      «      «      «      ‘Œ2 }}|S t        ‰ j                  «      g|D �cg c]
  } ||«      ‘Œ c}z   }|S |D �cg c]
  } ||«      ‘Œ }}|S c c}w c c}w c c}w )z=Packages Dataset into lists of dictionaries for transmission.c                 óÐ   •— ‰j                   rJ| j                  «       } ‰j                   D ]+  \  }}|€| D �cg c]
  } ||«      ‘Œ } }Œ || |   «      | |<   Œ- t        | «      S c c}w r   )re   r   r   )r   r!   ÚcallbackÚcellr   s       €r   Ú
format_rowz$Dataset._package.<locals>.format_row  so   ø€ à×ÒØ—h‘h“j�Ø%)×%5Ñ%5ò 6‘M�C˜Ø�{à:=Ö>°$™x¨�~Ð>˜Ñ>á#+¨C°©HÓ#5˜˜Cšð6ô ˜“9Ðùò ?s   ¶A#)r   rb   r`   Údictr‡   )r   Údictsrb   r¢   r   Údatas   `     r   Ú_packagezDataset._package  s¯   ø€ ô �T—Z‘ZÓ ˆô
	ð �<Š<ÙØRWÖXÈ3œœT¤# d§l¡l±J¸s³OÓ"DÓEÕFÐX�ÐXð
 ˆô ˜TŸ\™\Ó*Ð+È%Ö.PÀ3©z¸#­Ò.PÑP�ð ˆð 05Ö5¨‘J˜s•OÐ5ˆDÐ5Øˆùò Yùâ.Pùâ5s   ®5B-Â B2ÂB7c                 ó   — | j                   S )z³An *optional* list of strings to be used for header rows and attribute names.

        This must be set manually. The given list length must equal :attr:`Dataset.width`.

        )rc   r$   s    r   Ú_get_headerszDataset._get_headers)  s   € ð �~‰~Ðr   c                 óZ   — | j                  |«       |rt        |«      | _        yd| _        y)zValidating headers setter.N)rs   r   rc   )r   Ú
collections     r   Ú_set_headerszDataset._set_headers1  s$   € à�‰�zÔ"ÙÜ! *Ó-ˆD�Nà!ˆD�Nr   c                 ó"   — | j                  «       S )aÆ  A native Python representation of the :class:`Dataset` object. If headers have
        been set, a list of Python dictionaries will be returned. If no headers have been set,
        a list of tuples (rows) will be returned instead.

        A dataset object can also be imported by setting the `Dataset.dict` attribute: ::

            data = tablib.Dataset()
            data.dict = [{'age': 90, 'first_name': 'Kenneth', 'last_name': 'Reitz'}]

        )r¦   r$   s    r   Ú	_get_dictzDataset._get_dict;  s   € ð �}‰}‹Ðr   c           	      óÜ  — d}|syt        |t        «      st        |«      ‚t        |d   t        «      r2| j                  «        |D ]  }| j	                  t        |«      «       Œ yt        |d   t        «      rj| j                  «        t        |d   j                  «       «      | _        |D ]3  }| j	                  t        t        |j                  «       «      «      «       Œ5 yt        |«      ‚)aÃ  A native Python representation of the Dataset object. If headers have been
        set, a list of Python dictionaries will be returned. If no headers have been
        set, a list of tuples (rows) will be returned instead.

        A dataset object can also be imported by setting the :attr:`Dataset.dict` attribute. ::

            data = tablib.Dataset()
            data.dict = [{'age': 90, 'first_name': 'Kenneth', 'last_name': 'Reitz'}]

        z[Please check format documentation https://tablib.readthedocs.io/en/stable/formats.html#yamlNr   )
rO   r   r
   ÚwiperD   r   r£   Úkeysr`   Úvalues)r   ÚpickleÚerror_detailsr   s       r   Ú	_set_dictzDataset._set_dictH  sÌ   € ðHð 	ñ
 Øä˜&¤$Ô'ô $ MÓ2Ð2ô �f˜Q‘i¤Ô&Ø�I‰IŒKØò &�Ø—‘œC ›HÕ%ñ&ô ˜˜q™	¤4Ô(Ø�I‰IŒKÜ  q¡	§¡Ó 0Ó1ˆDŒLØò 5�Ø—‘œC¤ S§Z¡Z£\Ó 2Ó3Õ4ñ5ô $ MÓ2Ð2r   c                 óš   — t        |«      }t        |«      dk(  r1t        |d   d«      r"t        t        |d   | j                  «      «      }|S )zsPrepares the given column for insert/append. `col` is not supposed to
           contain any header value.
        r   r   Ú__call__)r   r'   Úhasattrr}   rb   )r   r!   s     r   Ú
_clean_colzDataset._clean_colq  sC   € ô
 �3‹iˆäˆs‹8�qŠ=œW S¨¡V¨ZÔ8Ü”s˜3˜q™6 4§:¡:Ó.Ó/ˆCàˆ
r   c                 ó,   — t        | j                  «      S )zfThe number of rows currently in the :class:`Dataset`.
           Cannot be directly modified.
        )r'   rb   r$   s    r   rk   zDataset.height}  s   € ô
 �4—:‘:‹Ðr   c                 óž   — 	 t        | j                  d   «      S # t        $ r) 	 t        | j                  «      cY S # t        $ r Y Y yw xY ww xY w)ziThe number of columns currently in the :class:`Dataset`.
           Cannot be directly modified.
        r   )r'   rb   Ú
IndexErrorr`   Ú	TypeErrorr$   s    r   r™   zDataset.width„  sO   € ð	Ü�t—z‘z !‘}Ó%Ð%øÜò 	ðÜ˜4Ÿ<™<Ó(Ò(øÜò Úðúð	ús)   ‚ š	A¤;¸A»	AÁAÁAÁAc                 ó¾   — t        |«      }|st        |«      }t        j                  |«      }t	        |d«      st        d|› d�«      ‚ |j                  | |fi |¤Ž | S )zù
        Import `in_stream` to the :class:`Dataset` object using the `format`.
        `in_stream` can be a file-like object, a string, or a bytestring.

        :param \*\*kwargs: (optional) custom configuration to the format `import_set`.
        r”   úFormat z cannot be imported.)r   Údetect_formatr   r�   r·   r
   r”   ©r   r•   rƒ   ri   ÚstreamÚfmts         r   ÚloadzDataset.load’  sd   € ô ! Ó+ˆÙÜ" 6Ó*ˆFä×!Ñ! &Ó)ˆÜ�s˜LÔ)Ü# g¨f¨XÐ5IÐ$JÓKÐKàˆ�‰�t˜VÑ. vÒ.Øˆr   c                 óˆ   — t        j                  |«      }t        |d«      st        d|› d�«      ‚ |j                  | fi |¤ŽS )z•
        Export :class:`Dataset` object to `format`.

        :param \*\*kwargs: (optional) custom configuration to the format `export_set`.
        r�   r¾   ú cannot be exported.)r   r�   r·   r
   r�   ©r   rƒ   ri   rÂ   s       r   ÚexportzDataset.export¥  sI   € ô ×!Ñ! &Ó)ˆÜ�s˜LÔ)Ü# g¨f¨XÐ5IÐ$JÓKÐKàˆs�~‰~˜dÑ- fÑ-Ð-r   c                 ó.  — | j                  |«       t        |«      | j                  k  rE| j                  j	                  «       D ](  \  }}t        |«      }|j                  | ||«      «       Œ* | j                  j                  |t        ||¬«      «       y)a­  Inserts a row to the :class:`Dataset` at the given index.

        Rows inserted must be the correct size (height or width).

        The default behaviour is to insert the given row to the :class:`Dataset`
        object at the given index.

        You can add :ref:`tags <tags>` to the row you are inserting.
        This gives you the ability to :method:`filter <Dataset.filter>` your
        :class:`Dataset` later.
        )r   N)	rs   r'   r™   rf   Úitemsr   r<   rb   r   )r   rF   r   r   ro   Úfuncs         r   r<   zDataset.insertµ  sz   € ð 	�‰�sÔÜˆs‹8�d—j‘jÒ Ø!×2Ñ2×8Ñ8Ó:ò +‘	��TÜ˜3“i�Ø—
‘
˜3¡ S£	Õ*ð+ð 	�
‰
×Ñ˜%¤ S¨tÔ!4Õ5r   c                 ó@   — | j                  | j                  ||¬«       y)zzAdds a row to the end of the :class:`Dataset`.
        See :method:`Dataset.insert` for additional documentation.
        ©r   r   N)r<   rk   r   s      r   r>   zDataset.rpushÉ  s   € ð
 	�‰�D—K‘K S¨tˆÕ4r   c                 ó,   — | j                  d||¬«       y)zzAdds a row to the top of the :class:`Dataset`.
        See :method:`Dataset.insert` for additional documentation.
        r   rÌ   Nr@   r   s      r   rA   zDataset.lpushÐ  s   € ð
 	�‰�A˜3 TˆÕ*r   c                 ó(   — | j                  ||«       y)zoAdds a row to the :class:`Dataset`.
        See :method:`Dataset.insert` for additional documentation.
        NrC   r   s      r   rD   zDataset.append×  s   € ð
 	�
‰
�3˜Õr   c                 ó6   — |D ]  }| j                  ||«       Œ y)z[Adds a list of rows to the :class:`Dataset` using
        :method:`Dataset.append`
        N)rD   )r   Úrowsr   r   s       r   r…   zDataset.extendÞ  s!   € ð
 ò 	#ˆCØ�K‰K˜˜TÕ"ñ	#r   c                 ó   — | d   }| d= |S )z:Removes and returns the first row of the :class:`Dataset`.r   r   ©r   Úcaches     r   ÚlpopzDataset.lpopæ  s   € ð �Q‘ˆØ�ˆGàˆr   c                 ó   — | d   }| d= |S )ú9Removes and returns the last row of the :class:`Dataset`.éÿÿÿÿr   rÒ   s     r   ÚrpopzDataset.rpopî  s   € ð �R‘ˆØ�ˆHàˆr   c                 ó"   — | j                  «       S )rÖ   )rØ   r$   s    r   ÚpopzDataset.popö  s   € ð �y‰y‹{Ðr   c                 óB   — t        |t        «      r| |   S t        d«      ‚)z=Returns the row from the :class:`Dataset` at the given index.zRow indices must be integers.)rO   Úintr¼   )r   rF   s     r   rg   zDataset.getû  s$   € ô �eœSÔ!Ø˜‘;ÐäÐ7Ó8Ð8r   c                 ó€  — |€g }t        |«      r8|| j                  | j                  <   t        t	        || j
                  «      «      }| j                  |«      }| j                  |¬«       | j                  rJ|s
t        «       ‚|r | j                  dk(  rt        |«      rt        ‚| j                  j                  ||«       | j                  rN| j                  rBt        | j
                  «      D ])  \  }}|j                  |||   «       || j
                  |<   Œ+ y|D �cg c]  }t        |g«      ‘Œ c}| _        yc c}w )a?  Inserts a column to the :class:`Dataset` at the given index.

        Columns inserted must be the correct height.

        You can also insert a column of a single callable object, which will
        add a new column with the return values of the callable each as an
        item in the column. ::

            data.append_col(col=random.randint)

        If inserting a column, and :attr:`Dataset.headers` is set, the
        header attribute must be set, and will be considered the header for
        that row.

        See :ref:`dyncols` for an in-depth example.
        N©r!   r   )Úcallablerf   r™   r   r}   rb   r¸   rs   r`   r   rk   r'   r	   r<   ru   r   )r   rF   r!   Úheaderr.   r   s         r   Ú
insert_colzDataset.insert_col  s  € ð$ ˆ;ØˆCô �CŒ=Ø03ˆD×!Ñ! $§*¡*Ñ-Ü”s˜3 §
¡
Ó+Ó,ˆCà�o‰o˜cÓ"ˆØ�‰˜3ˆÔà�<Š<áÜ#“oÐ%ñ ˜DŸK™K¨1Ò,´°S´Ü'Ð'à�L‰L×Ñ  vÔ.à�;Š;˜4Ÿ:š:ä# D§J¡JÓ/ò $‘��3à—
‘
˜5 # a¡&Ô)Ø #�—
‘
˜1’ñ$ð
 14Ö4¨œ#˜s˜e�*Ò4ˆD�JùÒ4s   ÄD;c                 ó@   — | j                  | j                  ||¬«       y)z}Adds a column to the end of the :class:`Dataset`.
        See :method:`Dataset.insert` for additional documentation.
        ©rà   N)rá   r™   ©r   r!   rà   s      r   Ú	rpush_colzDataset.rpush_col8  s   € ð
 	�‰˜Ÿ
™
 C°ˆÕ7r   c                 ó,   — | j                  d||¬«       y)z}Adds a column to the top of the :class:`Dataset`.
        See :method:`Dataset.insert` for additional documentation.
        r   rã   N)rá   rä   s      r   Ú	lpush_colzDataset.lpush_col?  s   € ð
 	�‰˜˜3 vˆÕ.r   c                 óB   — ||f}| j                   j                  |«       y)z4Adds a separator to :class:`Dataset` at given index.N)rd   rD   )r   rF   ÚtextÚseps       r   Úinsert_separatorzDataset.insert_separatorF  s!   € ð �dˆmˆØ×Ñ×Ñ Õ$r   c                 ó°   — | j                   s| j                  r| j                  nd}n| j                  r| j                  dz   nd}| j                  ||«       y)z=Adds a :ref:`separator <separators>` to the :class:`Dataset`.r   r   N)r`   rk   rë   )r   ré   rF   s      r   Úappend_separatorzDataset.append_separatorL  sA   € ð �|Š|Ø#'§;¢;�D—K’K°A‰Eà)-¯ª�T—[‘[ 1’_¸!ˆEà×Ñ˜e TÕ*r   c                 ó(   — | j                  ||«       y)zvAdds a column to the :class:`Dataset`.
        See :method:`Dataset.insert_col` for additional documentation.
        N)rå   rä   s      r   Ú
append_colzDataset.append_colW  s   € ð
 	�‰�s˜FÕ#r   c                 óF   — | j                   D �cg c]  }||   ‘Œ	 c}S c c}w )z@Returns the column from the :class:`Dataset` at the given index.)rb   )r   rF   r   s      r   Úget_colzDataset.get_col^  s    € ð '+§j¡jÖ1˜s��E“
Ò1Ð1ùÒ1s   �c                 óì   — t        |t        «      r0|| j                  v r| j                  j                  |«      }nt        ‚|�|| j
                  k  r| j                  j                  ||f«       yt        ‚)a'  Adds a formatter to the :class:`Dataset`.

        :param col: column to. Accepts index int, header str, or None to apply
                    the formatter to all columns.
        :param handler: reference to callback function to execute against
                        each cell value.
        T)	rO   rP   r`   rF   rm   r™   re   rD   r   )r   r!   Úhandlers      r   Úadd_formatterzDataset.add_formatterg  sh   € ô �cœ3ÔØ�d—l‘lÑ"Ø—l‘l×(Ñ(¨Ó-‘ä�àˆ;˜# §¡Ò+Ø×Ñ×#Ñ# S¨' NÔ3ð ô &Ð%r   c                 óˆ   — t        | «      }|j                  D �cg c]  }|j                  |«      sŒ|‘Œ c}|_        |S c c}w )z…Returns a new instance of the :class:`Dataset`, excluding any rows
        that do not contain the given :ref:`tags <tags>`.
        )r   rb   rT   )r   rS   Ú_dsetr   s       r   ÚfilterzDataset.filter}  s9   € ô �T“
ˆØ&+§k¡kÖF˜s°S·[±[ÀÕ5E’sÒFˆŒàˆùò Gs   š?±?c                 ó’  — t        |t        «      r‹| j                  st        ‚t	        | j
                  t        |«      |¬«      }t        | j                  | j                  ¬«      }|D ]0  }| j                  D �cg c]  }||   ‘Œ	 }}|j                  |¬«       Œ2 |S | j                  r| j                  |   }t	        | j
                  t        |«      |¬«      }t        | j                  | j                  ¬«      }|D ]?  }| j                  r| j                  D �cg c]  }||   ‘Œ	 }}n|}|j                  |¬«       ŒA |S c c}w c c}w )a  Sort a :class:`Dataset` by a specific column, given string (for
        header) or integer (for column index). The order can be reversed by
        setting ``reverse`` to ``True``.

        Returns a new :class:`Dataset` instance where columns have been
        sorted.
        )rn   Úreverse)r`   ra   ©r   )
rO   rP   r`   r   Úsortedr£   r   r\   ra   rD   )r   r!   rù   Ú_sortedrö   rI   rn   r   s           r   ÚsortzDataset.sort†  s  € ô �cœ3Ôà—<’<Ü#Ð#ä˜TŸY™Y¬J°s«OÀWÔMˆGÜ D§L¡L¸¿
¹
ÔCˆEàò &�Ø,0¯L©LÖ9 S�t˜C“yÐ9�Ð9Ø—‘ �Õ%ð&ð$ ˆð �|Š|Ø—l‘l 3Ñ'�ä˜TŸY™Y¬J°s«OÀWÔMˆGÜ D§L¡L¸¿
¹
ÔCˆEàò &�Ø—<’<Ø04·±Ö=¨˜4 ›9Ð=�CÑ=à�CØ—‘ �Õ%ð&ð ˆùò# :ùò >s   Á8D?ÄEc                 ó2  — t        «       }| j                  d   g| | j                  d      z   }||_        t        | j                  «      D ]J  \  }}|| j                  d   k(  rŒ|g| j                  |«      z   }t	        |«      }|j                  |¬«       ŒL |S )zÀTranspose a :class:`Dataset`, turning rows into columns and vice
        versa, returning a new ``Dataset`` instance. The first row of the
        original instance becomes the new header row.r   rú   )r\   r`   ru   rñ   r   rD   )r   rö   Únew_headersrF   ÚcolumnÚrow_datas         r   Ú_transpose_with_headerszDataset._transpose_with_headers«  sš   € ô
 “	ˆð —|‘| A‘Ð'¨$¨t¯|©|¸A©Ñ*?Ñ?ˆà#ˆŒÜ& t§|¡|Ó4ò 
	'‰MˆE�6à˜Ÿ™ a™Ò(àð �x $§,¡,¨uÓ"5Ñ5ˆHÜ˜8“}ˆHØ�L‰L˜XˆLÕ&ð
	'ð ˆr   c                 ó®   — t        «       }t        dt        | j                  d   «      «      D ]%  }| j	                  |«      }|j                  |¬«       Œ' |S )zÇTranspose a :class:`Dataset`, turning rows into columns and vice
        versa, returning a new ``Dataset`` instance. This instance should not
        have headers, or the dimension would be invalid.r   rú   )r\   Úranger'   rb   rñ   rD   )r   rö   rF   r  s       r   Ú_transpose_without_headersz"Dataset._transpose_without_headersÃ  sS   € ô
 “	ˆô ˜1œc $§*¡*¨Q¡-Ó0Ó1ò 	'ˆEØ—|‘| EÓ*ˆHØ�L‰L˜XˆLÕ&ð	'ð ˆr   c                 ó`   — | sy| j                   €| j                  «       S | j                  «       S )zåTranspose a :class:`Dataset`, turning rows into columns and vice
        versa, returning a new ``Dataset`` instance. If the instance has
        headers, the first row of the original instance becomes the new header
        row.N)r`   r  r  r$   s    r   Ú	transposezDataset.transposeÑ  s2   € ñ Øà�<‰<ÐØ×2Ñ2Ó4Ð4à×/Ñ/Ó1Ð1r   c                 ó$  — t        |t        «      sy| j                  |j                  k7  rt        ‚t	        | «      }|j
                  D �cg c]  }|‘Œ }}|j
                  D �cg c]  }|‘Œ }}|j                  |«       ||_        |S c c}w c c}w )zˆStack two :class:`Dataset` instances together by
        joining at the row level, and return new combined
        ``Dataset`` instance.N)rO   r\   r™   r	   r   rb   r…   )r   Úotherrö   r   Úrows_to_stackÚ
other_rowss         r   ÚstackzDataset.stackà  s‚   € ô
 ˜%¤Ô)Øà�:‰:˜Ÿ™Ò$Ü#Ð#ô �T“
ˆà(-¯©Ö4 šÐ4ˆÐ4Ø%*§[¡[Ö1˜c’cÐ1ˆ
Ð1à×Ñ˜ZÔ(Ø#ˆŒàˆùò 5ùÚ1s   Á
	BÁ#	Bc                 óâ  — t        |t        «      sy| j                  s|j                  r| j                  r|j                  st        ‚| j                  |j                  k7  rt
        ‚	 | j                  |j                  z   }t        «       }| j                  D ]  }|j                  | |   ¬«       Œ |j                  D ]  }|j                  ||   ¬«       Œ ||_        |S # t        $ r d}Y Œlw xY w)zÙStack two :class:`Dataset` instances together by
        joining at the column level, and return a new
        combined ``Dataset`` instance. If either ``Dataset``
        has headers set, than the other must as well.NrÞ   )rO   r\   r`   r   rk   r	   r¼   rï   )r   r	  rÿ   rö   r   s        r   Ú
stack_colszDataset.stack_colsö  sÝ   € ô ˜%¤Ô)Øà�<Š<˜5Ÿ=š=Ø—<’< u§}¢}Ü#Ð#à�;‰;˜%Ÿ,™,Ò&Ü#Ð#ð	ØŸ,™,¨¯©Ñ6ˆKô “	ˆà—l‘lò 	/ˆFØ×Ñ  f¡ÐÕ.ð	/ð —m‘mò 	0ˆFØ×Ñ  v¡ÐÕ/ð	0ð $ˆŒàˆøô ò 	ØŠKð	ús   Á(C  Ã C.Ã-C.c                 óÂ   — t        «       }| j                  D �cg c]-  }t        |«      |v rŒ|j                  t        |«      «      rŒ,|‘Œ/ c}| j                  dd yc c}w )ziRemoves all duplicate rows from the :class:`Dataset` object
        while maintaining the original order.N)rR   rb   rL   Úadd)r   Úseenr   s      r   Úremove_duplicateszDataset.remove_duplicates  sL   € ô ‹uˆàŸ:™:ö
Ø¬e°C«j¸DÒ.@ÀDÇHÁHÌUÐSVËZÕDXŠCò
ˆ�
‰
‘1‰ùò 
s   ™A¬AÁAc                 ó0   — t        «       | _        d| _        y)zARemoves all content and headers from the :class:`Dataset` object.N)r   rb   rc   r$   s    r   r¯   zDataset.wipe  s   € ä“VˆŒ
Øˆ�r   c                 ó€  — | sy|€t        t        | j                  «      «      }|€t        | j                  «      }|D �cg c]  }|t        | j                  «      v sŒ|‘Œ }}|D �cg c]  }|| j                  v sŒ|‘Œ }}t	        «       }t        |«      |_        g |_        t        | j
                  «      D ]{  \  }}g }|j                  D ]E  }|| j                  v r0| j                  j                  |«      }	|j                  ||	   «       ŒAt        ‚ ||v sŒa|j                  t        |«      ¬«       Œ} |S c c}w c c}w )zkReturns a new instance of the :class:`Dataset`,
        including only specified rows and columns.
        Nrú   )r   r  rk   r`   r\   rb   ru   rF   rD   rm   r   )
r   rÐ   Úcolsr   rà   rö   Úrow_noÚdata_rowrn   ro   s
             r   ÚsubsetzDataset.subset$  s'  € ñ Øàˆ<Üœ˜dŸk™kÓ*Ó+ˆDàˆ<Ü˜Ÿ™Ó%ˆDð  $ÖA˜ s¬e°D·K±KÓ.@Ò'@’ÐAˆÐAØ%)ÖD˜6¨V°t·|±|Ò-C’ÐDˆÐDä“	ˆô ˜T›
ˆŒàˆŒÜ$ T§Z¡ZÓ0ò 
	0‰KˆF�CØˆHØ—}‘}ò #�Ø˜$Ÿ,™,Ñ&ØŸ,™,×,Ñ,¨SÓ1�CØ—O‘O C¨¡HÕ-ä"�Nð#ð ˜Š~Ø—‘¤ X£�Õ/ð
	0ð ˆùò+ BùÚDs   ¿D6ÁD6Á&D;Á:D;)NNF)Tr   )r   )NN)r~   )F)6rU   rV   rW   rX   r   r(   r/   r2   r4   r+   r�   r’   r–   rs   r¦   r¨   r«   rZ   r`   r­   r´   r£   r¸   rk   r™   rÃ   rÇ   r<   r>   rA   rD   r…   rÔ   rØ   rÚ   rg   rá   rå   rç   rë   rí   rï   rñ   rô   r÷   rý   r  r  r  r  r  r  r¯   r  r   r   r   r\   r\   g   s4  „ ñ,ò\)ò"ò=ò%ò ò&&òGò2GòRóó2ò6ò"ñ �| \Ó2€Gòò%3ñN �I˜yÓ)€Dò
ð ñó ðð ñó ðóò&
.ó 6ó(5ó+óó#òòòò
9ó/5ób8ó/ó%ó	+ó$ò2òò,ó#òJò0ò2òò,òB
òô
%r   r\   c                   óR   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	e
d	„ «       Zd
„ Zd„ Zy)ÚDatabookz(A book of :class:`Dataset` objects.
    Nc                 ó   — |xs g | _         y r   ©Ú	_datasets)r   Úsetss     r   r   zDatabook.__init__P  s   € Øš ˆ�r   c                 ó\   — 	 d| j                   j                  «       z  S # t        $ r Y yw xY w)Nz<%s databook>z<databook object>rw   r$   s    r   r+   zDatabook.__repr__S  s1   € ð	'Ø" d§j¡j×&6Ñ&6Ó&8Ñ9Ð9øÜò 	'Ù&ð	'úrz   c                 ó   — g | _         y)z@Removes all :class:`Dataset` objects from the :class:`Databook`.Nr  r$   s    r   r¯   zDatabook.wipeY  s	   € àˆ�r   c                 ó   — | j                   S r   r  r$   s    r   ÚsheetszDatabook.sheets]  s   € Ø�~‰~Ðr   c                 óf   — t        |t        «      r| j                  j                  |«       yt        ‚)z5Adds given :class:`Dataset` to the :class:`Databook`.N)rO   r\   r  rD   r   )r   Údatasets     r   Ú	add_sheetzDatabook.add_sheet`  s$   € ä�gœwÔ'Ø�N‰N×!Ñ! 'Õ*ä$Ð$r   c                 ó„   — g }| j                   D ].  }|j                  |j                  |j                  «       dœ«       Œ0 |S )z(Packages :class:`Databook` for delivery.)ra   r¥   )r  rD   ra   r¦   )r   Ú	collectorÚdsets      r   r¦   zDatabook._packageg  sE   € àˆ	à—N‘Nò 	ˆDØ×ÑØŸ™ØŸ™›ñõ ð	ð
 Ðr   c                 ó,   — t        | j                  «      S )zDThe number of the :class:`Dataset` objects within :class:`Databook`.)r'   r  r$   s    r   ÚsizezDatabook.sizer  s   € ô �4—>‘>Ó"Ð"r   c                 ó¾   — t        |«      }|st        |«      }t        j                  |«      }t	        |d«      st        d|› d�«      ‚ |j                  | |fi |¤Ž | S )zû
        Import `in_stream` to the :class:`Databook` object using the `format`.
        `in_stream` can be a file-like object, a string, or a bytestring.

        :param \*\*kwargs: (optional) custom configuration to the format `import_book`.
        Úimport_bookr¾   z cannot be loaded.)r   r¿   r   r�   r·   r
   r,  rÀ   s         r   rÃ   zDatabook.loadw  sd   € ô ! Ó+ˆÙÜ" 6Ó*ˆFä×!Ñ! &Ó)ˆÜ�s˜MÔ*Ü# g¨f¨XÐ5GÐ$HÓIÐIàˆ�‰˜˜fÑ/¨Ò/Øˆr   c                 óˆ   — t        j                  |«      }t        |d«      st        d|› d�«      ‚ |j                  | fi |¤ŽS )z—
        Export :class:`Databook` object to `format`.

        :param \*\*kwargs: (optional) custom configuration to the format `export_book`.
        Úexport_bookr¾   rÅ   )r   r�   r·   r
   r.  rÆ   s       r   rÇ   zDatabook.exportŠ  sI   € ô ×!Ñ! &Ó)ˆÜ�s˜MÔ*Ü# g¨f¨XÐ5IÐ$JÓKÐKàˆs�‰˜tÑ. vÑ.Ð.r   r   )rU   rV   rW   rX   r   r+   r¯   r"  r%  r¦   rZ   r*  rÃ   rÇ   r   r   r   r  r  L  sC   „ ñó$ò'òòò%ò	ð ñ#ó ð#òó&
/r   r  c                 ór  — t        | «      } d}t        j                  «       D ]`  }	 |j                  | «      r-|j                  }	 t        | d«      r| j                  d«        |S 	 t        | d«      sŒP| j                  d«       Œb |S # t        $ r Y Œ-w xY w# t        | d«      r| j                  d«       w w xY w)zMReturn format name of given stream (file-like object, string, or bytestring).NÚseekr   )r   r   ÚformatsÚdetectra   r·   r0  ry   )rÁ   Ú	fmt_titlerÂ   s      r   r¿   r¿   —  s¹   € ä˜VÓ$€FØ€IÜ×ÑÓ!ò 	ˆð	Ø�z‰z˜&Ô!ØŸI™I�	Øô �v˜vÔ&Ø—‘˜A”øØÐð "ô �v˜vÕ&Ø—‘˜A•ð	ð Ðøô ò 	Ùð	ûô �v˜vÔ&Ø—‘˜A•ð 'ús)   ¦BÁ$BÂ	BÂBÂBÂBÂ B6Nc                 ó:   —  t        «       j                  | |fi |¤ŽS ©zIReturn dataset of given stream (file-like object, string, or bytestring).)r\   rÃ   ©rÁ   rƒ   ri   s      r   r”   r”   ¨  s   € ð Œ7‹9�>‰>˜& &Ñ3¨FÑ3Ð3r   c                 ó:   —  t        «       j                  | |fi |¤ŽS r5  )r  rÃ   r6  s      r   r,  r,  ®  s   € ð Œ8‹:�?‰?˜6 6Ñ4¨VÑ4Ð4r   r   )rX   r   Úoperatorr   Ú
exceptionsr   r   r   r	   r
   r1  r   Úutilsr   Ú	__title__Ú
__author__Ú__license__Ú__copyright__Ú__docformat__r   r\   r  r¿   r”   r,  Úregister_builtinsr   r   r   ú<module>rA     sƒ   ðñõ Ý ÷õ õ Ý "à€	Ø€
Ø€Ø>€Ø"€÷E8ñ E8÷Pbñ b÷JH/ñ H/òVó"4ó5ð €× Ñ Õ r   