§
    ŒŸjø!  ã                  ó^  — d Z ddlmZ ddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZmZ ddlmZ d	d
lmZ d	dlmZmZ d	dlmZ  e e	dd¦  «        ¦  «         e e	dd¦  «        ¦  «         e e	dd¦  «        ¦  «         e e	dd¦  «        ¦  «         e e	dd¦  «        ¦  «         e e	dd¦  «        ¦  «        iZ e e	ddd¦  «        ¦  «        Z e e	dd¦  «        ¦  «        ZdD ]2Z e e	dde¦  «        ¦  «        Z e e	de¦  «        ¦  «        Zeee<   Œ3g d¢Zej         Z! e!d¦  «        d e!d¦  «        d e!d¦  «        d e!d¦  «        d  e!d!¦  «        d"iZ"d8d%„Z#d9d)„Z$d:d;d-„Z%d9d.„Z&d9d/„Z'd<d3„Z(d=d4„Z) G d5„ d6e¦  «        Z*e*j+        Z,e-d7k    r e,¦   «          dS dS )>a  Migrating IPython < 4.0 to Jupyter

This *copies* configuration and resources to their new locations in Jupyter

Migrations:

- .ipython/
  - nbextensions -> JUPYTER_DATA_DIR/nbextensions
  - kernels ->  JUPYTER_DATA_DIR/kernels

- .ipython/profile_default/
  - static/custom -> .jupyter/custom
  - nbconfig -> .jupyter/nbconfig
  - security/

    - notebook_secret, notebook_cookie_secret, nbsignatures.db -> JUPYTER_DATA_DIR

  - ipython_{notebook,nbconvert,qtconsole}_config.py -> .jupyter/jupyter_{name}_config.py


é    )ÚannotationsN)ÚdatetimeÚtimezone)ÚPath)ÚAny)ÚJSONFileConfigLoaderÚPyFileConfigLoader)Ú
get_loggeré   )Ú
JupyterApp)Újupyter_config_dirÚjupyter_data_dir)Úensure_dir_existsz{ipython_dir}Únbextensionsz{jupyter_data}Úkernelsz	{profile}Únbconfigz{jupyter_config}ÚstaticÚcustom)Únotebook_secretÚnotebook_cookie_secretznbsignatures.dbÚsecurity)ÚnotebookÚ	nbconvertÚ	qtconsolez\bIPythonQtConsoleApp\bÚJupyterQtConsoleAppz\bIPythonWidget\bÚJupyterWidgetz\bRichIPythonWidget\bÚRichJupyterWidgetz\bIPython\.html\br   z\bIPython\.nbconvert\br   ÚreturnÚstrc                 óš   — t           j                             dt          t	          d¦  «                             ¦   «         ¦  «        ¦  «        S )a£  Return the IPython directory location.

    Not imported from IPython because the IPython implementation
    ensures that a writable directory exists,
    creating a temporary directory if not.
    We don't want to trigger that when checking if migration should happen.

    We only need to support the IPython < 4 behavior for migration,
    so importing for forward-compatibility and edge cases is not important.
    Ú
IPYTHONDIRz
~/.ipython)ÚosÚenvironÚgetr   r   Ú
expanduser© ó    úa/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/jupyter_core/migrate.pyÚget_ipython_dirr)   H   s6   € õ Œ:�>Š>˜,­­D°Ñ,>Ô,>×,IÒ,IÑ,KÔ,KÑ(LÔ(LÑMÔMÐMr'   ÚsrcÚdstÚboolc                ó  — t          ¦   «         }t          | ¦  «        }t          |¦  «        }t          |                     ¦   «         ¦  «        s|                     d| ¦  «         dS |                     ¦   «         rMt          |                     ¦   «         ¦  «        r|                     d|¦  «         dS |                     ¦   «          |                     d| |¦  «         t          |j	        ¦  «         t          j        | |d¬¦  «         dS )z#Migrate a directory from src to dstzNo files in %sFú%s already existsúCopying %s -> %sT)Úsymlinks)r
   r   ÚanyÚiterdirÚdebugÚexistsÚrmdirÚinfor   ÚparentÚshutilÚcopytree)r*   r+   ÚlogÚsrc_pathÚdst_paths        r(   Úmigrate_dirr=   V   sò   € å
‰,Œ,€CÝ�C‰yŒy€HÝ�C‰yŒy€HÝˆx×ÒÑ!Ô!Ñ"Ô"ð Ø�	Š	Ð" CÑ(Ô(Ð(ØˆuØ‡‚ÑÔð Ýˆx×ÒÑ!Ô!Ñ"Ô"ð 	à�IŠIÐ)¨3Ñ/Ô/Ð/Ø�5Ø�ŠÑÔÐØ‡H‚HÐ  cÑ*Ô*Ð*Ý�h”oÑ&Ô&Ð&Ý
„O�C˜ tÐ,Ñ,Ô,Ð,Øˆ4r'   ú
str | PathÚsubstitutionsr   c                ó€  — t          ¦   «         }t          |¦  «        }|                     ¦   «         r|                     d|¦  «         dS |                     d| |¦  «         t          |j        ¦  «         t          j        | |¦  «         |r²| 	                    ¦   «         5 }| 
                    ¦   «         }ddd¦  «         n# 1 swxY w Y   |                     ¦   «         D ]\  }}|                     ||¦  «        }Œ| 	                    d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   dS )z’Migrate a single file from src to dst

    substitutions is an optional dict of {regex: replacement} for performing replacements on the file.
    r.   Fr/   NÚwT)r
   r   r4   r3   r6   r   r7   r8   ÚcopyÚopenÚreadÚitemsÚsubÚwrite)	r*   r+   r?   r:   r<   ÚfÚtextÚpatÚreplacements	            r(   Úmigrate_filerL   j   sŸ  € õ
 ‰,Œ,€CÝ�C‰yŒy€HØ‡‚ÑÔð à�	Š	Ð% sÑ+Ô+Ð+ØˆuØ‡H‚HÐ  cÑ*Ô*Ð*Ý�h”oÑ&Ô&Ð&Ý
„K��SÑÔÐØð Ø�]Š]‰_Œ_ð 	 Ø—6’6‘8”8ˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	à -× 3Ò 3Ñ 5Ô 5ð 	.ð 	.ÑˆC�Ø—7’7˜;¨Ñ-Ô-ˆDˆDØ�]Š]˜3ÑÔð 	 1Ø�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	àˆ4s$   Â CÃCÃCÄD3Ä3D7Ä:D7c                ó  — t          ¦   «         }t          | ¦  «                             ¦   «         rt          | |¦  «        S t          | ¦  «                             ¦   «         rt          | |¦  «        S |                     d| ¦  «         dS )z:Migrate one item

    dispatches to migrate_dir/_file
    zNothing to migrate for %sF)r
   r   Úis_filerL   Úis_dirr=   r3   )r*   r+   r:   s      r(   Úmigrate_onerP   ‚   s{   € õ
 ‰,Œ,€CÝˆC�y„y×ÒÑÔð &Ý˜C Ñ%Ô%Ð%ÝˆC�y„y×ÒÑÔð %Ý˜3 Ñ$Ô$Ð$Ø‡I‚IÐ)¨3Ñ/Ô/Ð/Øˆ5r'   c                óz  — t          ¦   «         }d}t          | d¦  «        }t          | d¦  «        }d}t          |¦  «                             ¦   «         rªt          j        |d¬¦  «        5 }|                     ¦   «                              ¦   «         }|                     ¦   «         D ]A}	|	                     ¦   «         s+|	                     ¦   «                              d¦  «        sd} nŒBddd¦  «         n# 1 swxY w Y   d}
t          |¦  «                             ¦   «         r~t          j        |d¬¦  «        5 }|                     ¦   «                              ¦   «         }|                     d	¦  «        o| 	                    d
¦  «        }
ddd¦  «         n# 1 swxY w Y   |r| 
                    d|¦  «         |
r| 
                    d|¦  «         |r|
rdS t          |¦  «         |r|
st          |¦  «         |s t          |t          |d¦  «        ¦  «        rd}|
s t          |t          |d¦  «        ¦  «        rd}|S )zvMigrate non-empty custom.js,css from src to dst

    src, dst are 'custom' directories containing custom.{js,css}
    Fz	custom.jsz
custom.cssTúutf-8©Úencoding)ú/*Ú*z//NrU   z*/zIgnoring empty %s)r
   r   rN   rC   rD   ÚstripÚ
splitlinesÚisspaceÚ
startswithÚendswithr3   r   rL   )r*   r+   r:   ÚmigratedÚ	custom_jsÚ
custom_cssÚcustom_js_emptyrH   ÚjsÚlineÚcustom_css_emptyÚcsss               r(   Úmigrate_static_customrd   �   sÅ  € õ
 ‰,Œ,€CØ€Hå�S˜+Ñ&Ô&€IÝ�c˜<Ñ(Ô(€Jà€OÝˆI�„×ÒÑ Ô ð ÝŒY�y¨7Ð3Ñ3Ô3ð 	°qØ—’‘”—’Ñ!Ô!ˆBØŸš™œð ð �ØŸš™œð ¨$¯*ª*©,¬,×*AÒ*AÐBSÑ*TÔ*Tð Ø&+�OØ�Eøð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð ÐÝˆJÑÔ×ÒÑ!Ô!ð KÝŒY�z¨GÐ4Ñ4Ô4ð 	K¸Ø—&’&‘(”(—.’.Ñ"Ô"ˆCØ"Ÿ~š~¨dÑ3Ô3ÐJ¸¿ºÀTÑ8JÔ8JÐð	Kð 	Kð 	Kñ 	Kô 	Kð 	Kð 	Kð 	Kð 	Kð 	Kð 	Køøøð 	Kð 	Kð 	Kð 	Kð ð 2Ø�	Š	Ð% yÑ1Ô1Ð1Øð 3Ø�	Š	Ð% zÑ2Ô2Ð2àð Ð+ð àˆuÝ�cÑÔÐàð Ð"2ð Ý˜#ÑÔÐàð �|¨Iµt¸CÀÑ7MÔ7MÑNÔNð ØˆØð ¥¨Z½¸cÀ<Ñ9PÔ9PÑ QÔ Qð Øˆà€Os&   Á*A=C3Ã3C7Ã:C7Ä7AFÆFÆFÚnameÚenvú	list[Any]c                ó  — t          ¦   «         }t          t          |d         › d| › d�¦  «        ¦  «        }t          t          |d         › d| › d�¦  «        ¦  «        }t          t          dœ}g }dD ]•}||z   }||z   }	t          |¦  «                             ¦   «         rh ||         |¦  «                             ¦   «         }
|
r-t          ||	t          ¬¦  «        r| 	                    |¦  «         Œ| 
                    d|¦  «         Œ–|S )	zWMigrate a config file.

    Includes substitutions for updated configurable names.
    ÚprofileÚipython_Ú_configÚjupyter_configÚjupyter_)z.pyz.json)r?   z#Not migrating empty config file: %s)r
   r   r   r	   r   r4   Úload_configrL   Úconfig_substitutionsÚappendr3   )re   rf   r:   Úsrc_baseÚdst_baseÚloadersr\   Úextr*   r+   Úcfgs              r(   Úmigrate_configrv   À   s*  € õ
 ‰,Œ,€CÝ•4˜3˜yœ>Ð+Ð-E¸Ð-EÐ-EÐ-EÑFÔFÑGÔG€HÝ•4˜3Ð/Ô0Ð2Ð4L¸tÐ4LÐ4LÐ4LÑMÔMÑNÔN€Hå!Ý%ðð €Gð €HØð 
Fð 
FˆØ˜‰nˆØ˜‰nˆÝ�‰9Œ9×ÒÑÔð 	FØ�'˜#”,˜sÑ#Ô#×/Ò/Ñ1Ô1ˆCØð FÝ  SÕ8LÐMÑMÔMð )Ø—O’O CÑ(Ô(Ð(øð —	’	Ð?ÀÑEÔEÐEøØ€Or'   c            	     ó   — t          ¦   «         t          ¦   «         t          ¦   «         t          t	          t          ¦   «         d¦  «        ¦  «        dœ} d}t
                               ¦   «         D ]R\  }} |j        di | ¤Ž} |j        di | ¤Ž}t	          |¦  «                             ¦   «         rt          ||¦  «        rd}ŒSt          D ]}t          || ¦  «        rd}Œt          j        di | ¤Ž}t          j        di | ¤Ž}t	          |¦  «                             ¦   «         rt          ||¦  «        rd}t          | d         ¦  «         t	          j        t	          | d         d¦  «        dd¬	¦  «        5 }	|	                     t%          j        t(          j        ¬
¦  «                             ¦   «         ¦  «         ddd¦  «         n# 1 swxY w Y   |S )z(Migrate IPython configuration to JupyterÚprofile_default)Újupyter_datarl   Úipython_dirri   FTrl   r\   rA   rR   rS   )ÚtzNr&   )r   r   r)   r   r   Ú
migrationsrE   Úformatr4   rP   Úconfig_migrationsrv   Úcustom_src_tÚcustom_dst_trd   r   rC   rG   r   Únowr   ÚutcÚ	isoformat)
rf   r\   Úsrc_tÚdst_tr*   r+   re   Ú
custom_srcÚ
custom_dstrH   s
             r(   Úmigraterˆ   Û   s  € õ )Ñ*Ô*Ý,Ñ.Ô.Ý&Ñ(Ô(Ý•t�OÑ-Ô-Ð/@ÑAÔAÑBÔBð	ð €Cð €HÝ"×(Ò(Ñ*Ô*ð ð ‰ˆˆuØˆeŒlÐ!Ð!˜SÐ!Ð!ˆØˆeŒlÐ!Ð!˜SÐ!Ð!ˆÝ�‰9Œ9×ÒÑÔð 	¥+¨c°3Ñ"7Ô"7ð 	ØˆHøå!ð ð ˆÝ˜$ Ñ$Ô$ð 	ØˆHøåÔ$Ð+Ð+ sÐ+Ð+€JÝÔ$Ð+Ð+ sÐ+Ð+€JåˆJÑÔ×ÒÑ Ô ð Õ%:¸:ÀzÑ%RÔ%Rð Øˆõ �cÐ*Ô+Ñ,Ô,Ð,Ý	Œ•4˜Ð,Ô-¨zÑ:Ô:¸CÈ'Ð	RÑ	RÔ	Rð ;ÐVWØ	�Š•”¥¤Ð-Ñ-Ô-×7Ò7Ñ9Ô9Ñ:Ô:Ð:ð;ð ;ð ;ñ ;ô ;ð ;ð ;ð ;ð ;ð ;ð ;øøøð ;ð ;ð ;ð ;ð €Os   Å2AGÇGÇ
Gc                  ó"   — e Zd ZdZdZdZdd„ZdS )	ÚJupyterMigratezA Jupyter Migration App.zjupyter-migratea©  
    Migrate configuration and data from .ipython prior to 4.0 to Jupyter locations.

    This migrates:

    - config files in the default profile
    - kernels in ~/.ipython/kernels
    - notebook javascript extensions in ~/.ipython/extensions
    - custom.js/css to .jupyter/custom

    to their new Jupyter locations.

    All files are copied, not moved.
    If the destinations already exist, nothing will be done.
    r   ÚNonec                óZ   — t          ¦   «         s| j                             d¦  «         dS dS )zStart the application.zFound nothing to migrate.N)rˆ   r:   r6   )Úselfs    r(   ÚstartzJupyterMigrate.start  s3   € å‰yŒyð 	7ØŒH�MŠMÐ5Ñ6Ô6Ð6Ð6Ð6ð	7ð 	7r'   N)r   r‹   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__re   ÚdescriptionrŽ   r&   r'   r(   rŠ   rŠ   ü   s:   € € € € € Ø"Ð"à€Dð€Kð 7ð 7ð 7ð 7ð 7ð 7r'   rŠ   Ú__main__)r   r   )r*   r   r+   r   r   r,   )N)r*   r>   r+   r>   r?   r   r   r,   )re   r   rf   r   r   rg   )r   r,   ).r’   Ú
__future__r   r"   Úrer8   r   r   Úpathlibr   Útypingr   Útraitlets.config.loaderr   r	   Útraitlets.logr
   Úapplicationr   Úpathsr   r   Úutilsr   r   r|   r   r€   Úsecurity_filer*   r+   r~   ÚcompileÚregexro   r)   r=   rL   rP   rd   rv   rˆ   rŠ   Úlaunch_instanceÚmainr�   r&   r'   r(   ú<module>r£      sk  ððð ð0 #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø 	€	€	€	Ø €€€Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à LÐ LÐ LÐ LÐ LÐ LÐ LÐ LØ $Ð $Ð $Ð $Ð $Ð $à #Ð #Ð #Ð #Ð #Ð #Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø $Ð $Ð $Ð $Ð $Ð $ð €Cˆˆˆ_˜nÑ-Ô-Ñ.Ô.°°°D°DÐ9IÈ>Ñ4ZÔ4ZÑ0[Ô0[Ø€Cˆˆˆ_˜iÑ(Ô(Ñ)Ô)¨3¨3¨t¨tÐ4DÀiÑ/PÔ/PÑ+QÔ+QØ€Cˆˆˆ[˜*Ñ%Ô%Ñ&Ô&¨¨¨D¨DÐ1CÀZÑ,PÔ,PÑ(QÔ(Qð€
ð ˆs�4�4˜ X¨xÑ8Ô8Ñ9Ô9€Øˆs�4�4Ð*¨HÑ5Ô5Ñ6Ô6€àUð ð €MØ
ˆ#ˆdˆd�; 
¨MÑ:Ô:Ñ
;Ô
;€CØ
ˆ#ˆdˆdÐ# ]Ñ3Ô3Ñ
4Ô
4€CØ€Jˆs�O€Oà:Ð:Ð:Ð à
Œ
€ð 
€EÐ
$Ñ%Ô%Ð'<Ø	€EÐ
ÑÔ Ø	€EÐ
"Ñ#Ô#Ð%8Ø	€EÐ
ÑÔ Ø	€EÐ
#Ñ$Ô$ kðÐ ðNð Nð Nð Nðð ð ð ð(ð ð ð ð ð0ð ð ð ð-ð -ð -ð -ð`ð ð ð ð6ð ð ð ðB7ð 7ð 7ð 7ð 7�Zñ 7ô 7ð 7ð4 Ô%€ð ˆzÒÐØ€D�F„F€F€F€Fð Ðr'   