§
    �Ÿjá  ã                   ó®   — d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ dd„Zd„ Zd	„ Zd
„ Ze	 G d„ de¦  «        ¦   «         Zd„ ZdS )zõ
%store magic for lightweight persistence.

Stores variables, aliases and macros in IPython's database.

To automatically restore stored variables at startup, add this to your
:file:`ipython_config.py` file::

  c.StoreMagics.autorestore = True
é    N)Ú
UsageError)ÚMagicsÚmagics_classÚ
line_magic)Úskip_doctest)ÚBoolc                 óð   — | j                              di ¦  «        }|€7|                     ¦   «         D ] \  }}| j                             ||¦  «         Œ!d S | j                             |||         ¦  «         d S )NÚstored_aliases)ÚdbÚgetÚitemsÚalias_managerÚdefine_alias)ÚipÚaliasÚ	staliasesÚkÚvs        új/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/extensions/storemagic.pyÚrestore_aliasesr      sˆ   € Ø”—	’	Ð*¨BÑ/Ô/€IØ€}Ø—?’?Ñ$Ô$ð 	/ð 	/‰CˆAˆað Ô×)Ò)¨!¨AÑ.Ô.Ð.Ð.ð	/ð 	/ð
 	Ô×%Ò% e¨Y°uÔ-=Ñ>Ô>Ð>Ð>Ð>ó    c                 ó:  — | j         }|                     d¦  «        D ]}}t          j                             |¦  «        }	 ||         }|| j        |<   Œ5# t          $ r< t          d|z  ¦  «         t          dt          j	        ¦   «         d         ¦  «         Y Œzw xY wd S )Núautorestore/*zEUnable to restore variable '%s', ignoring (use %%store -d to forget!)zThe error was:r   )
r   ÚkeysÚosÚpathÚbasenameÚuser_nsÚKeyErrorÚprintÚsysÚexc_info)r   r   ÚkeyÚjustkeyÚobjs        r   Úrefresh_variablesr&   #   s¶   € Ø	Œ€BØ�wŠw�Ñ'Ô'ð 
&ð 
&ˆå”'×"Ò" 3Ñ'Ô'ˆð	&Ø�S”'ˆCð #&ˆBŒJ�wÑÐøõ ð 	7ð 	7ð 	7ÝÐYÐ\cÑcÑdÔdÐdÝÐ"¥C¤L¡N¤N°1Ô$5Ñ6Ô6Ð6Ð6Ð6ð	7øøøð
&ð 
&s   ¿AÁABÂBc                 óL   — | j                              dg ¦  «        | j        d<   d S )NÚdhistÚ_dh)r   r   r   ©r   s    r   Úrestore_dhistr+   2   s$   € ØœŸ	š	 '¨"Ñ-Ô-€B„JˆuÑÐÐr   c                 ó`   — t          | ¦  «         t          | ¦  «         t          | ¦  «         d S ©N)r&   r   r+   r*   s    r   Úrestore_datar.   6   s2   € Ý�bÑÔÐÝ�BÑÔÐÝ�"ÑÔÐÐÐr   c                   óŒ   ‡ — e Zd ZdZ edd¬¦  «                             d¬¦  «        Zˆ fd„Zee	d
d	„¦   «         ¦   «         Z
ˆ xZS )ÚStoreMagicszMLightweight persistence for python variables.

    Provides the %store magic.FzdIf True, any %store-d variables will be automatically restored
        when IPython starts.
        )ÚhelpT)Úconfigc                 óÒ   •— t          t          | ¦  «                             |¬¦  «         | j        j                             | ¦  «         | j        rt          | j        ¦  «         d S d S )N)Úshell)Úsuperr0   Ú__init__r4   ÚconfigurablesÚappendÚautorestorer.   )Úselfr4   Ú	__class__s     €r   r6   zStoreMagics.__init__H   sh   ø€ Ý�k˜4Ñ Ô ×)Ò)°Ð)Ñ6Ô6Ð6ØŒ
Ô ×'Ò'¨Ñ-Ô-Ð-ØÔð 	%Ý˜œÑ$Ô$Ð$Ð$Ð$ð	%ð 	%r   Ú c                 óR	  — |                       |dd¬¦  «        \  }}|                     ¦   «         }| j        }|j        }d|v rY	 |d         }	 |d|z   = dS # t          $ r}t          d|z  ¦  «        |‚d}~ww xY w# t          $ r}t          d	¦  «        |‚d}~ww xY wd
|v r|                     d¦  «        D ]}	||	= ŒdS d|v ru|rb|D ]]}
	 |d|
z            }||j        |
<   Œ# t          $ r8 	 t          ||
¬¦  «         n"# t          $ r t          d|
z  ¦  «         Y nw xY wY ŒZw xY wdS t          |¦  «         dS |sÔ|                     d¦  «        }|                     ¦   «          |r#t          t          t           |¦  «        ¦  «        }nd}t          d¦  «         dt#          |¦  «        z   dz   }|j        }|D ]T}t&          j                             |¦  «        }t          ||t-           ||d¦  «        ¦  «        dd…         fz  ¦  «         ŒUdS t!          |¦  «        dk    �rm|d                              d¦  «        �rQt&          j                             |d                              d¦  «                             ¦   «         ¦  «        }|d                              d¦  «        rt5          |dd¬¦  «        }nt5          |dd¬¦  «        }|5  |                     |d         ¦  «        }t          d|d         ›d|j        j        ›d|›d�¦  «         t=          |t"          ¦  «        sddlm}  |||¦  «         n?|                      |¦  «         | !                    d ¦  «        s|                      d ¦  «         ddd¦  «         n# 1 swxY w Y   dS |D �]}
	 |j        |
         }tE          tG          j$        |¦  «        d!d"¦  «        }|d#k    r+t          tK          j&        d$|
›d%|›d&�¦  «        ¦  «          dS ||d|
z   <   t          d'|
›d|j        j        ›d(�¦  «         ŒŽ# t          $ r~ |
}	 |j'         (                    |¦  «        }n%# tR          $ r}t          d)|z  ¦  «        |‚d}~ww xY w|                     d*i ¦  «        }|||<   ||d*<   t          d+|›d,|›d(�¦  «         Y  dS w xY wdS )-aŽ  Lightweight persistence for python variables.

        Example::

          In [1]: l = ['hello',10,'world']
          In [2]: %store l
          Stored 'l' (list)
          In [3]: exit

          (IPython session is closed and started again...)

          ville@badger:~$ ipython
          In [1]: l
          NameError: name 'l' is not defined
          In [2]: %store -r
          In [3]: l
          Out[3]: ['hello', 10, 'world']

        Usage:

        * ``%store``          - Show list of all variables and their current
                                values
        * ``%store spam bar`` - Store the *current* value of the variables spam
                                and bar to disk
        * ``%store -d spam``  - Remove the variable and its value from storage
        * ``%store -z``       - Remove all variables from storage
        * ``%store -r``       - Refresh all variables, aliases and directory history
                                from store (overwrite current vals)
        * ``%store -r spam bar`` - Refresh specified variables and aliases from store
                                   (delete current val)
        * ``%store foo >a.txt``  - Store value of foo to new file a.txt
        * ``%store foo >>a.txt`` - Append value of foo to file a.txt

        It should be noted that if you change the value of a variable, you
        need to %store it again if you want to persist the new value.

        Note also that the variables will need to be pickleable; most basic
        python types can be safely %store'd.

        Also aliases can be %store'd across sessions.
        To remove an alias from the storage, use the %unalias magic.
        ÚdrzÚstring)ÚmodeÚdr   zautorestore/zCan't delete variable '%s'Nz'You must provide the variable to forgetÚzr   Úr)r   zno stored variable or alias %sz(Stored variables and their in-db values:z%-zs -> %sz<unavailable>é2   é   ú>z>>Úazutf-8)ÚencodingÚwz	Writing 'z' (z) to file 'z'.)Úpprintú
Ú__name__r<   Ú__main__z                         Warning:z is a  
                        Proper storage of interactively declared classes (or instances
                        of those classes) is not possible! Only instances
                        of classes in real modules on file system can be %store'd.
                        zStored 'ú)zUnknown variable '%s'r
   zAlias stored: z ()*Úparse_optionsÚsplitr4   r   ÚBaseExceptionr   Ú
IndexErrorr   r   r   r   r    r.   ÚsortÚmaxÚmapÚlenÚstrr   r   r   r   ÚreprÚ
startswithÚ
expanduserÚlstripÚopenÚevr;   rL   Ú
isinstancerJ   ÚwriteÚendswithÚgetattrÚinspectÚ	getmoduleÚtextwrapÚdedentr   Úretrieve_aliasÚ
ValueError)r:   Úparameter_sÚoptsÚargslÚargsr   r   ÚtodelÚer   Úargr%   ÚvarsÚsizeÚfmtr   Úvarr$   ÚfnamÚfilrJ   ÚmodnameÚnameÚcmdr   s                            r   ÚstorezStoreMagics.storeN   s$  € ð\ ×'Ò'¨°E¸xÐ'ÑHÔH‰
ˆˆUØ�{Š{‰}Œ}ˆØŒZˆØŒUˆà�$ˆ;ˆ;ðRØ˜Qœ�ðRØ˜>¨EÑ1Ð2Ð2Ð2øÝ$ð Rð Rð RÝ$Ð%AÀEÑ%IÑJÔJÐPQÐQøøøøðRøøøøõ ð Sð Sð SÝ Ð!JÑKÔKÐQRÐRøøøøðSøøøð �Dˆ[ˆ[Ø—W’W˜_Ñ-Ô-ð ð �Ø�q�E�Eðð ð �Dˆ[ˆ[Øð !Øð 	.ð 	.�Cð.Ø  °#Ñ!5Ô6˜ð +.˜œ
 3™˜øõ $ð Jð Jð JðJÝ+¨B°cÐ:Ñ:Ô:Ð:Ð:øÝ'ð Jð Jð JÝ!Ð"BÀSÑ"HÑIÔIÐIÐIÐIðJøøøøøðJøøøð	.ð 	.õ ˜RÑ Ô Ð Ð Ð ð ð F	NØ—7’7˜?Ñ+Ô+ˆDØ�IŠI‰KŒKˆKØð Ý�3�s D™>œ>Ñ*Ô*��à�åÐ<Ñ=Ô=Ð=Ø•s˜4‘y”y‘. Ñ*ˆCØ”&ˆCØð Mð M�Ýœ'×*Ò*¨3Ñ/Ô/�å�c˜W¥d¨3¨3¨s°OÑ+DÔ+DÑ&EÔ&EÀcÀrÀcÔ&JÐKÑKÑLÔLÐLÐLðMð Mõ �4‰yŒy˜1Š}‰}  a¤×!3Ò!3°CÑ!8Ô!8‰}Ý”w×)Ò)¨$¨q¬'¯.ª.¸Ñ*=Ô*=×*DÒ*DÑ*FÔ*FÑGÔG�Ø˜”7×%Ò% dÑ+Ô+ð <Ý˜t S°7Ð;Ñ;Ô;�C�Cå˜t S°7Ð;Ñ;Ô;�CØð ,ð ,ØŸ%š%  Q¤™.œ.�CÝ�E¸tÀA¼w¸w¸wØœÔ.Ð.Ð.°°°ð6ñ 7ô 7ð 7õ & s­CÑ0Ô0ð ,Ø1Ð1Ð1Ð1Ð1Ð1Ø˜˜s CÑ(Ô(Ð(Ð(àŸ	š	 #™œ˜Ø"Ÿ|š|¨DÑ1Ô1ð ,ØŸIšI d™OœO˜Oð,ð ,ð ,ñ ,ô ,ð ,ð ,ð ,ð ,ð ,ð ,øøøð ,ð ,ð ,ð ,ð �ð ð Nñ N�ðNØœ* Sœ/�Cõ  &¥gÔ&7¸Ñ&<Ô&<¸jÈ"ÑMÔM�GØ *Ò,Ð,Ý�hœo˜oð
  #˜s˜s C C Cð/)ñ +ô +ñ ,ô ,ð ,ð ˜˜à14�B˜¨Ñ,Ñ.Ý�E°°°°S´]Ô5KÐ5KÐ5KÐLÑMÔMÐMÐMøõ5  ð ð ð à�DðPØ Ô.×=Ò=¸dÑCÔC˜˜øÝ%ð Pð Pð PÝ(Ð)@À4Ñ)GÑHÔHÈaÐOøøøøðPøøøð !#§¢Ð'7¸Ñ ;Ô ;�IØ&)�I˜d‘OØ+4�BÐ'Ñ(Ý�E°T°T°T¸3¸3¸3Ð?Ñ@Ô@Ð@Ø�F�F�FðøøøðNð Ns¯   ÁA9 ÁA Á
A6ÁA1Á1A6Á9
BÂBÂBÃCÃ
DÃ(C:Ã9DÃ:DÄDÄDÄDÄDËB,M?Í?NÎNÎPÐR$Ð)QÑR$Ñ
Q&ÑQ!Ñ!Q&Ñ&9R$Ò#R$)r<   )rL   Ú
__module__Ú__qualname__Ú__doc__r   Útagr9   r6   r   r   rx   Ú__classcell__)r;   s   @r   r0   r0   <   s¯   ø€ € € € € ð"ð "ð �$�uð	ðñ ô ÷ 
‚c�€cÑÔð	 ð%ð %ð %ð %ð %ð ØðVNð VNð VNñ „Zñ „\ðVNð VNð VNð VNð VNr   r0   c                 ó:   — |                       t          ¦  «         dS )zLoad the extension in IPython.N)Úregister_magicsr0   r*   s    r   Úload_ipython_extensionr€   é   s   € à×Ò•{Ñ#Ô#Ð#Ð#Ð#r   r-   )r{   rb   r   r!   rd   ÚIPython.core.errorr   ÚIPython.core.magicr   r   r   ÚIPython.testing.skipdoctestr   Ú	traitletsr   r   r&   r+   r.   r0   r€   © r   r   ú<module>r†      s6  ðð	ð 	ð "Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ð !à )Ð )Ð )Ð )Ð )Ð )Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø Ð Ð Ð Ð Ð ð?ð ?ð ?ð ?ð&ð &ð &ð.ð .ð .ðð ð ð ðiNð iNð iNð iNð iN�&ñ iNô iNñ „ðiNðX$ð $ð $ð $ð $r   