ó
    Ñ]j!  ã                   ó    • S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
JrJr  SSKJrJrJr  SS	KJr   " S
 S\5      r " S S\5      rg)z3An object for managing IPython profile directories.é    N)ÚPath)ÚLoggingConfigurableé   )Úget_ipython_package_dir)Úexpand_pathÚensure_dir_exists)ÚUnicodeÚBoolÚobserve)ÚOptionalc                   ó   • \ rS rSrSrg)ÚProfileDirErroré   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/IPython/core/profiledir.pyr   r      s   † Úr   r   c                   ó  • \ rS rSrSr\" S5      r\" S5      r\" S5      r\" S5      r	\" S5      r
\" S5      r\" S5      r\" S5      r\" S5      r\" S5      r\" SS	S
9R!                  SS9r\" S5      r\" S5      S 5       rS%S\S\\   S\4S jjr\" S5      S%S j5       r\" S5      S%S j5       r\" S5      S%S j5       r\" S5      S%S j5       rS rS&S\S\ S\4S jjr!\"S%S  j5       r#\"S'S! j5       r$\"S'S" j5       r%\"S%S# j5       r&S$r'g)(Ú
ProfileDiré   a,  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                 óV  • U R                   (       a  [        S5      eSU l         US   n[        U5        [        R                  R                  X R                  5      U l        [        R                  R                  X R                  5      U l	        [        R                  R                  X R                  5      U l        [        R                  R                  X R                  5      U l        [        R                  R                  X R                  5      U l        U R!                  5         g )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_changedÚProfileDir._location_changed:   sÀ   € à××ÜÐLÓMÐMØ#ˆÔØ�U‰mˆÜ˜#Ôô ŸG™GŸL™L¨×.DÑ.DÓEˆÔÜ—w‘w—|‘| C×):Ñ):Ó;ˆŒÜŸ7™7Ÿ<™<¨×-BÑ-BÓCˆÔÜ—w‘w—|‘| C×):Ñ):Ó;ˆŒÜŸ'™'Ÿ,™, s×,@Ñ,@ÓAˆŒØ�‰Õr   Nr)   ÚmodeÚreturnc                 ó  • [         R                  R                  U5      (       aD  U(       a<  [         R                  " U5      R                  U:w  a   [         R
                  " X5        gg U(       a  [         R                  " X5        g[         R                  " U5         g! [         a    U R                  R                  SU5         gf = f! [         a)  nUR                  [        R                  :X  a   SnAge SnAff = f)a  ensure a directory exists at a given path

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

- returns whether the directory has been created or not.
- 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

Parameters
----------
path: str
    path of the dir to create
mode: int
    see `mode` of `os.mkdir`

Returns
-------
bool:
    returns True if it created the directory, False otherwise
zCould not set permissions on %sFNT)r(   r)   ÚexistsÚstatÚst_modeÚchmodÚOSErrorr   ÚwarningÚmkdirÚerrnoÚEEXIST)r6   r)   r:   Úes       r   Ú_mkdirÚProfileDir._mkdirJ   sÅ   € ô0 �7‰7�>‰>˜$×ÑÞœŸš ›×-Ñ-°Ó5ðÜ—H’H˜TÔ(ñ ð		ÞÜ—’˜Ô$ð ô —’˜•ð øô# ó Ø—H‘H×$Ñ$Ø9Øõð ðûô ó 	Ø�w‰wœ%Ÿ,™,Ó&Üàûð		ús6   ÁB  Á*C ÂC Â &C	ÃC	Ã
C?ÃC:Ã9C:Ã:C?r.   c                 ó:   • U R                  U R                  5        g ©N)rG   r.   ©r6   r7   s     r   Úcheck_log_dirÚProfileDir.check_log_diry   s   € à�‰�D—L‘LÕ!r   r0   c                 óæ  • U R                  U R                  5      (       aÑ  [        R                  R	                  U R                  S5      n[        R                  R	                  [        5       SSS5      n[        R                  R                  U5      (       a<  [        R                  R                  U5      (       d  [        R                  " X25        g g U R                  R                  SU5        g g )NÚREADMEÚcoreÚprofileÚREADME_STARTUPzLCould not copy README_STARTUP to startup dir. Source file %s does not exist.)rG   r0   r(   r)   r*   r   r=   ÚshutilÚcopyr   rB   )r6   r7   ÚreadmeÚsrcs       r   Úcheck_startup_dirÚProfileDir.check_startup_dir}   s¨   € à�;‰;�t×'Ñ'×(Ñ(Ü—W‘W—\‘\ $×"2Ñ"2°HÓ=ˆFÜ—'‘'—,‘,Ü'Ó)¨6°9Ð>NóˆCô �w‰w�~‰~˜c×"Ñ"Ü—w‘w—~‘~ f×-Ñ-Ü—K’K Õ,ð .ð —‘× Ñ ØbØõð )r   r,   c                 ó<   • U R                  U R                  S5        g ©NiÀA  )rG   r,   rK   s     r   Úcheck_security_dirÚProfileDir.check_security_dirŽ   s   € à�‰�D×%Ñ% wÕ/r   r2   c                 ó<   • U R                  U R                  S5        g rZ   )rG   r2   rK   s     r   Úcheck_pid_dirÚProfileDir.check_pid_dir’   s   € à�‰�D—L‘L 'Õ*r   c                 ó„   • U R                  5         U R                  5         U R                  5         U R                  5         g rJ   )r[   rL   r^   rW   )r6   s    r   r5   ÚProfileDir.check_dirs–   s2   € Ø×ÑÔ!Ø×ÑÔØ×ÑÔØ×ÑÕ r   Úconfig_filec                 ó`  • [        [        R                  R                  U R                  U5      5      nUR                  5       (       a  U(       d  gUc*  [        R                  R                  [        5       SSS5      n[        U[         5      (       d   eX!-  n[        R                  " XT5        g)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.
FrP   rQ   ÚdefaultT)
r   r(   r)   r*   r#   r=   r   Ú
isinstancerS   rT   )r6   rb   r)   Ú	overwriteÚdstrV   s         r   Úcopy_config_fileÚProfileDir.copy_config_fileœ   s}   € ô ”2—7‘7—<‘< §¡¨{Ó;Ó<ˆØ�:‰:�<‰<¦	ØØ‰<Ü—7‘7—<‘<Ô 7Ó 9¸7ÀJÐPZÓ[ˆDÜ˜$¤×%Ñ%Ð%Ð%ØÑ ˆÜ�Š�CÔØr   c                 ó   • U " XS9$ )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_dirÚProfileDir.create_profile_dir­   s   € ñ ˜KÑ7Ð7r   c                 ó¸   • [         R                  R                  U5      (       d  [        SU-  5      e[         R                  R	                  USU-   5      nU " XCS9$ )zÿ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_rk   )r(   r)   Úisdirr   r*   )rm   r)   Únamer"   rn   s        r   Úcreate_profile_dir_by_nameÚ%ProfileDir.create_profile_dir_by_name¹   sL   € ô �w‰w�}‰}˜T×"Ñ"Ü!Ð";¸dÑ"BÓCÐCÜ—g‘g—l‘l 4¨°tÑ);Ó<ˆÙ˜KÑ7Ð7r   c                 óÖ   • SU-   nU/nU HN  n[         R                  R                  Xd5      n[         R                  R                  U5      (       d  MH  U " XsS9s  $    [	        SU-  5      e)aþ  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>".
rr   rk   z(Profile directory not found in paths: %s)r(   r)   r*   rs   r   )rm   Úipython_dirrt   r"   ÚdirnameÚpathsÚprn   s           r   Úfind_profile_dir_by_nameÚ#ProfileDir.find_profile_dir_by_nameÊ   sb   € ð&  Ñ$ˆØ�ˆÛˆAÜŸ'™'Ÿ,™, qÓ2ˆKÜ�w‰w�}‰}˜[×)Ó)Ù KÑ?Ò?ñ ô
 "Ð"LÈwÑ"VÓWÐWr   c                 óˆ   • [        U5      n[        R                  R                  U5      (       d  [	        SU-  5      eU " XS9$ )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: %srk   )r   r(   r)   rs   r   rl   s      r   Úfind_profile_dirÚProfileDir.find_profile_diræ   s=   € ô " +Ó.ˆÜ�w‰w�}‰}˜[×)Ñ)Ü!Ð"CÀkÑ"QÓRÐRÙ˜KÑ7Ð7r   )r&   r.   r2   r,   r0   r4   rJ   )F)rd   N)(r   r   r   r   Ú__doc__r	   r+   r-   r/   r1   r3   r,   r.   r0   r2   r4   Útagr#   r
   r&   r   r8   Ústrr   ÚintÚboolrG   rL   rW   r[   r^   r5   r   rh   Úclassmethodro   ru   r|   r   r   r   r   r   r   r      s¡  † ññ   
Ó+ÐÙ˜5“>€LÙ˜yÓ)ÐÙ˜5“>€LÙ˜hÓ'€OÙ˜3“<€LÙ�c‹l€GÙ˜#“,€KÙ�c‹l€GÙ˜“€Já�sðñ
÷ ‰#�Tˆ#Ð
ð ñ
 ˜5“k€OÙˆZÓñó ðñ-˜3ð - h¨s¡mð -¸tõ -ñ^ ˆYÓó"ó ð"ñ ˆ]Óóó ðñ  ˆ^Óó0ó ð0ñ ˆYÓó+ó ð+ò!ñ¨Cð °tð ÐQUõ ð" ó	8ó ð	8ð ó8ó ð8ð  óXó ðXð6 ó8ó ó8r   r   )r�   r(   rS   rD   Úpathlibr   Útraitlets.config.configurabler   rz   r   Ú
utils.pathr   r   Ú	traitletsr	   r
   r   Útypingr   Ú	Exceptionr   r   r   r   r   Ú<module>r�      sC   ðá 9ó
 
Û Û Ý å =Ý +ß 7ß ,Ñ ,å ô	�iô 	ôU8Ð$õ U8r   