§
    �Ÿj]  ã                   ó¢   — d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZmZ  G d	„ d
e¦  «        Z G d„ de¦  «        ZdS )z3An object for managing IPython profile directories.é    N)ÚPath)ÚLoggingConfigurableé   )Úget_ipython_package_dir)Úexpand_pathÚensure_dir_exists)ÚUnicodeÚBoolÚobservec                   ó   — e Zd ZdS )ÚProfileDirErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/core/profiledir.pyr   r      s   € € € € € Ø€Dr   r   c                   óš  — e Zd ZdZ ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z	 ed¦  «        Z
 ed¦  «        Z ed¦  «        Z ed¦  «        Z ed¦  «        Z edd¬	¦  «                             d
¬¦  «        Z ed¦  «        Z ed¦  «        d„ ¦   «         Zd#d„Z ed¦  «        d#d„¦   «         Z ed¦  «        d#d„¦   «         Z ed¦  «        d#d„¦   «         Z ed¦  «        d#d„¦   «         Zd„ Zd$dededefd„Zed#d„¦   «         Z ed%d „¦   «         Z!ed%d!„¦   «         Z"ed#d"„¦   «         Z#dS )&Ú
ProfileDira@  An object to manage the profile directory and its resources.

    The profile directory is used by all IPython applications, to manage
    configuration, logging and security.

    This object knows how to find, create and manage these directories. This
    should be used by any code that wants to handle profiles.
    ÚsecurityÚlogÚstartupÚpidÚstaticÚ zaSet the profile location directly. This overrides the logic used by the
        `profile` option.)ÚhelpT)ÚconfigFÚlocationc                 ó:  — | j         rt          d¦  «        ‚d| _         |d         }t          |¦  «         t          j                             || j        ¦  «        | _        t          j                             || j        ¦  «        | _	        t          j                             || j
        ¦  «        | _        t          j                             || j        ¦  «        | _        t          j                             || j        ¦  «        | _        |                      ¦   «          d S )Nz+Cannot set profile location more than once.TÚnew)Ú_location_issetÚRuntimeErrorr   ÚosÚpathÚjoinÚsecurity_dir_nameÚsecurity_dirÚlog_dir_nameÚlog_dirÚstartup_dir_nameÚstartup_dirÚpid_dir_nameÚpid_dirÚstatic_dir_nameÚ
static_dirÚ
check_dirs)ÚselfÚchanger    s      r   Ú_location_changedzProfileDir._location_changed8   sØ   € àÔð 	NÝÐLÑMÔMÐMØ#ˆÔØ�UŒmˆÝ˜#ÑÔÐõ œGŸLšL¨¨dÔ.DÑEÔEˆÔÝ”w—|’| C¨Ô):Ñ;Ô;ˆŒÝœ7Ÿ<š<¨¨TÔ-BÑCÔCˆÔÝ”w—|’| C¨Ô):Ñ;Ô;ˆŒÝœ'Ÿ,š, s¨DÔ,@ÑAÔAˆŒØ�ŠÑÔÐÐÐr   Nc                 óÂ  — t           j                             |¦  «        rc|r_t          j        |¦  «        j        |k    rB	 t          j        ||¦  «         n+# t          $ r | j                             d|¦  «         Y nw xY wdS 	 |rt          j	        ||¦  «         nt          j	        |¦  «         n.# t          $ r!}|j
        t          j        k    rY d}~dS ‚ d}~ww xY wdS )a�  ensure a directory exists at a given path

        This is a version of os.mkdir, with the following differences:

        - returns True if it created the directory, False otherwise
        - ignores EEXIST, protecting against race conditions where
          the dir may have been created in between the check and
          the creation
        - sets permissions if requested and the dir already exists
        zCould not set permissions on %sFNT)r#   r$   ÚexistsÚstatÚst_modeÚchmodÚOSErrorr   ÚwarningÚmkdirÚerrnoÚEEXIST)r1   r$   ÚmodeÚes       r   Ú_mkdirzProfileDir._mkdirH   s  € õ Œ7�>Š>˜$ÑÔð 		Øð �œ ™œÔ-°Ò5Ð5ðÝ”H˜T 4Ñ(Ô(Ð(Ð(øÝð ð ð Ø”H×$Ò$Ø9Øñô ð ð ð ðøøøð
 �5ð		Øð Ý”˜˜tÑ$Ô$Ð$Ð$å”˜‘”�øøÝð 	ð 	ð 	ØŒw�%œ,Ò&Ð&Ø�u�u�u�u�uàøøøøð		øøøð ˆts0   Á A Á%A>Á=A>Â,B1 Â1
CÂ;CÃCÃCr)   c                 ó:   — |                       | j        ¦  «         d S ©N)r@   r)   ©r1   r2   s     r   Úcheck_log_dirzProfileDir.check_log_dirj   s   € à�Š�D”LÑ!Ô!Ð!Ð!Ð!r   r+   c                 ó  — |                       | j        ¦  «         t          j                             | j        d¦  «        }t          j                             t          ¦   «         ddd¦  «        }t          j                             |¦  «        s| j                             d|¦  «         t          j                             |¦  «        r6t          j                             |¦  «        st          j
        ||¦  «         d S d S d S )NÚREADMEÚcoreÚprofileÚREADME_STARTUPzLCould not copy README_STARTUP to startup dir. Source file %s does not exist.)r@   r+   r#   r$   r%   r   r5   r   r:   ÚshutilÚcopy)r1   r2   ÚreadmeÚsrcs       r   Úcheck_startup_dirzProfileDir.check_startup_dirn   sØ   € à�Š�DÔ$Ñ%Ô%Ð%å”—’˜dÔ.°Ñ9Ô9ˆÝŒg�lŠlÕ2Ñ4Ô4°g¸zÐK\Ñ]Ô]ˆåŒw�~Š~˜cÑ"Ô"ð 	rØŒH×ÒÐkÐmpÑqÔqÐqåŒ7�>Š>˜#ÑÔð 	%¥r¤w§~¢~°fÑ'=Ô'=ð 	%ÝŒK˜˜VÑ$Ô$Ð$Ð$Ð$ð	%ð 	%ð 	%ð 	%r   r'   c                 ó<   — |                       | j        d¦  «         d S ©NiÀA  )r@   r'   rC   s     r   Úcheck_security_dirzProfileDir.check_security_dir{   s   € à�Š�DÔ% wÑ/Ô/Ð/Ð/Ð/r   r-   c                 ó<   — |                       | j        d¦  «         d S rP   )r@   r-   rC   s     r   Úcheck_pid_dirzProfileDir.check_pid_dir   s   € à�Š�D”L 'Ñ*Ô*Ð*Ð*Ð*r   c                 ó¦   — |                       ¦   «          |                      ¦   «          |                      ¦   «          |                      ¦   «          d S rB   )rQ   rD   rS   rN   )r1   s    r   r0   zProfileDir.check_dirsƒ   sP   € Ø×ÒÑ!Ô!Ð!Ø×ÒÑÔÐØ×ÒÑÔÐØ×ÒÑ Ô Ð Ð Ð r   Úconfig_filer$   Úreturnc                 ó\  — t          t          j                             | j        |¦  «        ¦  «        }|                     ¦   «         r|sdS |€.t          j                             t          ¦   «         ddd¦  «        }t          |t           ¦  «        sJ ‚||z  }t          j	        ||¦  «         dS )zóCopy a default config file into the active profile directory.

        Default configuration files are kept in :mod:`IPython.core.profile`.
        This function moves these from that location to the working profile
        directory.
        FNrG   rH   ÚdefaultT)
r   r#   r$   r%   r   r5   r   Ú
isinstancerJ   rK   )r1   rU   r$   Ú	overwriteÚdstrM   s         r   Úcopy_config_filezProfileDir.copy_config_file‰   sœ   € õ •2”7—<’< ¤¨{Ñ;Ô;Ñ<Ô<ˆØ�:Š:‰<Œ<ð 	 	ð 	Ø�5Øˆ<Ý”7—<’<Õ 7Ñ 9Ô 9¸7ÀJÐPZÑ[Ô[ˆDÝ˜$¥Ñ%Ô%Ð%Ð%Ð%Ø�[Ñ ˆÝŒ�C˜ÑÔÐØˆtr   c                 ó   —  | ||¬¦  «        S )züCreate a new profile directory given a full path.

        Parameters
        ----------
        profile_dir : str
            The full path to the profile directory.  If it does exist, it will
            be used.  If not, it will be created.
        ©r   r   r   ©ÚclsÚprofile_dirr   s      r   Úcreate_profile_dirzProfileDir.create_profile_dirš   s   € ð ˆs˜K°Ð7Ñ7Ô7Ð7r   rX   c                 óÄ   — t           j                             |¦  «        st          d|z  ¦  «        ‚t           j                             |d|z   ¦  «        } | ||¬¦  «        S )a?  Create a profile dir by profile name and path.

        Parameters
        ----------
        path : unicode
            The path (directory) to put the profile directory in.
        name : unicode
            The name of the profile.  The name of the profile directory will
            be "profile_<profile>".
        zDirectory not found: %sÚprofile_r^   )r#   r$   Úisdirr   r%   )r`   r$   Únamer   ra   s        r   Úcreate_profile_dir_by_namez%ProfileDir.create_profile_dir_by_name¦   s^   € õ Œw�}Š}˜TÑ"Ô"ð 	DÝ!Ð";¸dÑ"BÑCÔCÐCÝ”g—l’l 4¨°tÑ);Ñ<Ô<ˆØˆs˜K°Ð7Ñ7Ô7Ð7r   c                 óÜ   — d|z   }|g}|D ]P}t           j                             ||¦  «        }t           j                             |¦  «        r | ||¬¦  «        c S ŒQt	          d|z  ¦  «        ‚)af  Find an existing profile dir by profile name, return its ProfileDir.

        This searches through a sequence of paths for a profile dir.  If it
        is not found, a :class:`ProfileDirError` exception will be raised.

        The search path algorithm is:
        1. ``os.getcwd()`` # removed for security reason.
        2. ``ipython_dir``

        Parameters
        ----------
        ipython_dir : unicode or str
            The IPython directory to use.
        name : unicode or str
            The name of the profile.  The name of the profile directory
            will be "profile_<profile>".
        rd   r^   z(Profile directory not found in paths: %s)r#   r$   r%   re   r   )r`   Úipython_dirrf   r   ÚdirnameÚpathsÚpra   s           r   Úfind_profile_dir_by_namez#ProfileDir.find_profile_dir_by_name·   s‰   € ð&  Ñ$ˆØ�ˆØð 	Xð 	XˆAÝœ'Ÿ,š, q¨'Ñ2Ô2ˆKÝŒw�}Š}˜[Ñ)Ô)ð @Ø�s K¸Ð?Ñ?Ô?Ð?Ð?Ð?ð@õ "Ð"LÈwÑ"VÑWÔWÐWr   c                 óœ   — t          |¦  «        }t          j                             |¦  «        st	          d|z  ¦  «        ‚ | ||¬¦  «        S )zýFind/create a profile dir and return its ProfileDir.

        This will create the profile directory if it doesn't exist.

        Parameters
        ----------
        profile_dir : unicode or str
            The path of the profile directory.
        zProfile directory not found: %sr^   )r   r#   r$   re   r   r_   s      r   Úfind_profile_dirzProfileDir.find_profile_dirÓ   sQ   € õ " +Ñ.Ô.ˆÝŒw�}Š}˜[Ñ)Ô)ð 	SÝ!Ð"CÀkÑ"QÑRÔRÐRØˆs˜K°Ð7Ñ7Ô7Ð7r   rB   )F)rX   N)$r   r   r   Ú__doc__r	   r&   r(   r*   r,   r.   r'   r)   r+   r-   r/   Útagr   r
   r!   r   r3   r@   rD   rN   rQ   rS   r0   Ústrr   Úboolr\   Úclassmethodrb   rg   rm   ro   r   r   r   r   r      s‘  € € € € € ðð ð  ˜ 
Ñ+Ô+ÐØ�7˜5‘>”>€LØ�w˜yÑ)Ô)ÐØ�7˜5‘>”>€LØ�g˜hÑ'Ô'€OØ�7˜3‘<”<€LØˆg�c‰lŒl€GØ�'˜#‘,”,€KØˆg�c‰lŒl€GØ�˜‘”€Jàˆw�sðð
ñ 
ô 
÷ Š#�Tˆ#Ñ
Ô
ð ð
 �d˜5‘k”k€OØ€WˆZÑÔðð ñ Ôðð ð  ð  ð  ðD €WˆYÑÔð"ð "ð "ñ Ôð"ð €Wˆ]ÑÔð
%ð 
%ð 
%ñ Ôð
%ð €Wˆ^ÑÔð0ð 0ð 0ñ Ôð0ð €WˆYÑÔð+ð +ð +ñ Ôð+ð!ð !ð !ðð ¨Cð °tð ÐQUð ð ð ð ð" ð	8ð 	8ð 	8ñ „[ð	8ð ð8ð 8ð 8ñ „[ð8ð  ðXð Xð Xñ „[ðXð6 ð8ð 8ð 8ñ „[ð8ð 8ð 8r   r   )rp   r#   rJ   r<   Úpathlibr   Útraitlets.config.configurabler   rk   r   Ú
utils.pathr   r   Ú	traitletsr	   r
   r   Ú	Exceptionr   r   r   r   r   ú<module>rz      sý   ðà 9Ð 9ð
 
€	€	€	Ø €€€Ø €€€Ø Ð Ð Ð Ð Ð à =Ð =Ð =Ð =Ð =Ð =Ø +Ð +Ð +Ð +Ð +Ð +Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,ð	ð 	ð 	ð 	ð 	�iñ 	ô 	ð 	ðD8ð D8ð D8ð D8ð D8Ð$ñ D8ô D8ð D8ð D8ð D8r   