§
    ŒŸj×˜  ã                  óÈ  — U d Z ddlmZ ddlZddlZddl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 ddlmZ ddlmZmZ ddlZej        j        Zej        dk    s%ej        d	k    rej                             d
¦  «        sdZndZ eedd¦  «        ZedOdPd„¦   «         ZedQd„¦   «         ZdOdRd„ZdSd„ZdTd„Zi Z de!d<   dUd„Z"dSd „Z#dVd!„Z$dTd"„Z%dTd#„Z&dTd$„Z' ed%¦  «        Z(de!d&<   dZ)d'e!d(<   ej*        d)k    re(rej+         ,                    d*d¦  «        Z) e¦   «         rVej*        d)k    re(s e- eej        d+d¦  «        ¦  «        gZ.nh ej/        edd,¬-¦  «         0                    ej1        ¦  «        Z.n<ej*        d)k    r-e)r ee)d¦  «        gZ.n! e- eej        d+d¦  «        ¦  «        gZ.nd.d/gZ. e- eej        d+d¦  «        ¦  «        gZ2d0e!d1<   dWd3„Z3 e- eej        d4d¦  «        ¦  «        gZ4d0e!d5<    e¦   «         rDej*        d)k    re(se4dd…         Z5n_ ej6        edd,¬-¦  «         0                    ej1        ¦  «        Z5n3ej*        d)k    r$e)r e- ee)d¦  «        ¦  «        gZ5ne4dd…         Z5nd6d7gZ5dXd8„Z7dUd9„Z8dYdZd>„Z9dYdZd?„Z:ej        dk    re9Z;ne:Z;d[d\dB„Z<d]dD„Z=d]dE„Z>d^dG„Z? ej@        dHdI¦  «         A                    ¦   «         dJv ZBedOd_dM„¦   «         ZCd`dN„ZDdS )azPath utility functions.é    )ÚannotationsN)ÚIterator)Úcontextmanager)ÚPath)ÚAnyÚoverloadÚwin32Údarwinz/opt/homebrewÚJupyterÚjupyterÚ	UF_HIDDENi €  FÚnameÚstrÚdefaultÚboolÚreturnc                ó   — d S ©N© ©r   r   s     ú_/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/jupyter_core/paths.pyÚenvsetr   (   s   € Ø69°có    ÚNoneúbool | Nonec                ó   — d S r   r   r   s     r   r   r   ,   s   € Ø58°Sr   c                ón   — | t           j        vr|S t           j        |                               ¦   «         dvS )a%  Return the boolean value of a given environment variable.

    An environment variable is considered set if it is assigned to a value
    other than 'no', 'n', 'false', 'off', '0', or '0.0' (case insensitive)

    If the environment variable is not defined, the default value is returned.
    )ÚnoÚnÚfalseÚoffÚ0z0.0)ÚosÚenvironÚlowerr   s     r   r   r   0   s5   € ð •2”:ÐÐØˆåŒ:�dÔ×!Ò!Ñ#Ô#Ð+RÐRÐRr   c                 ó"   — t          dd¦  «        S )zcDetermine if platformdirs should be used for system-specific paths.

    The default is False.
    ÚJUPYTER_PLATFORM_DIRSF)r   r   r   r   Úuse_platform_dirsr(   >   s   € õ
 Ð)¨5Ñ1Ô1Ð1r   c                 ó    — t          d¦  «                             ¦   «         } t          t          | ¦  «                             ¦   «         ¦  «        S )z'Get the real path of the home directoryú~)r   Ú
expanduserr   Úresolve)Úhomedirs    r   Úget_home_dirr.   F   s;   € å�3‰iŒi×"Ò"Ñ$Ô$€Gõ �t�G‰}Œ}×$Ò$Ñ&Ô&Ñ'Ô'Ð'r   zdict[str, str]Ú_dtempsÚpathc                ó:  — t          | ¦  «                             ¦   «         }|                     ¦   «         s1||j        k    r&|j        }|                     ¦   «         s||j        k    °&	 |                     ¦   «         t          j        ¦   «         k    S # t          $ r Y nw xY wt          t
          d¦  «        rH	 | 	                    ¦   «         }|j
        t          j        ¦   «         k    S # t          t          f$ r Y nw xY wt          j        |t
          j        ¦  «        S )z3Return whether the current user owns the given pathÚgeteuid)r   r,   ÚexistsÚparentÚownerr#   ÚgetloginÚ	ExceptionÚhasattrÚstatÚst_uidr2   ÚNotImplementedErrorÚOSErrorÚaccessÚW_OK)r0   ÚpÚsts      r   Ú	_do_i_ownrA   Q   s
  € åˆT‰
Œ
×ÒÑÔ€Að �hŠh‰jŒjð ˜Q !¤(š]˜]ØŒHˆð �hŠh‰jŒjð ˜Q !¤(š]˜]ð
Ø�wŠw‰yŒy�BœK™MœMÒ)Ð)øÝð ð ð Øˆðøøøõ �r�9ÑÔð ð	Ø—’‘”ˆBØ”9¥¤
¡¤Ò,Ð,øÝ#¥WÐ-ð 	ð 	ð 	àˆDð	øøøõ
 Œ9�Q�œÑ Ô Ð s$   Á((B Â
BÂBÂ7/C' Ã'C;Ã:C;c                 ó¢  — dt           j        v rt          d¦  «        S t          j        t          j        k    rt          t          j        ¦  «        rdS dt           j        v rnt          j                             t           j        d         ¦  «        r?t           j                             dd¦  «        dk    rt          t          j        ¦  «        rdS dS )zRDetermine if environment-level paths should take precedence over user-level paths.ÚJUPYTER_PREFER_ENV_PATHTÚCONDA_PREFIXÚCONDA_DEFAULT_ENVÚbaseF)	r#   r$   r   ÚsysÚprefixÚbase_prefixrA   Ú
startswithÚgetr   r   r   Úprefer_environment_over_userrL   l   s®   € ð !¥B¤JÐ.Ð.ÝÐ/Ñ0Ô0Ð0õ „z•S”_Ò$Ð$­µ3´:Ñ)>Ô)>Ð$Øˆtð 	�"œ*Ð$Ð$ÝŒJ×!Ò!¥"¤*¨^Ô"<Ñ=Ô=ð 	%åŒJ�NŠNÐ.°Ñ7Ô7¸6ÒAÐAÝ•c”jÑ!Ô!ð Bð ˆtàˆ5r   c                ó†   — 	 t           |          S # t          $ r' t          j        | dz   ¬¦  «        x}t           | <   |cY S w xY w)z�Make or reuse a temporary directory.

    If this is called with the same name in the same process, it will return
    the same directory.
    ú-)rH   )r/   ÚKeyErrorÚtempfileÚmkdtemp)r   Úds     r   Ú_mkdtemp_oncerS   ‚   sU   € ðÝ�tŒ}ÐøÝð ð ð Ý$Ô,°D¸3±JÐ?Ñ?Ô?Ð?ˆ�G�D‰MØˆˆˆðøøøs   ‚ �.A ¿A c                 ó*  — t           j        } |                      d¦  «        rt          d¦  «        S |                      d¦  «        r| d         S t	          ¦   «         rt          j        t          d¬¦  «        S t          ¦   «         }t          |d¦  «        S )z§Get the Jupyter config directory for this platform and user.

    Returns JUPYTER_CONFIG_DIR if defined, otherwise the appropriate
    directory for the platform.
    ÚJUPYTER_NO_CONFIGzjupyter-clean-cfgÚJUPYTER_CONFIG_DIRF©Ú	appauthorz.jupyter)
r#   r$   rK   rS   r(   ÚplatformdirsÚuser_config_dirÚAPPNAMEr.   Úpjoin)ÚenvÚhome_dirs     r   Újupyter_config_dirr_   �   sŽ   € õ Œ*€CØ
‡w‚wÐ"Ñ#Ô#ð 2ÝÐ0Ñ1Ô1Ð1à
‡w‚wÐ#Ñ$Ô$ð )ØÐ'Ô(Ð(åÑÔð FÝÔ+­G¸uÐEÑEÔEÐEå‰~Œ~€HÝ�˜:Ñ&Ô&Ð&r   c                 óŠ  — t           j        } |                      d¦  «        r| d         S t          ¦   «         rt	          j        t          d¬¦  «        S t          ¦   «         }t          j	        dk    rt          t          |dd¦  «        ¦  «        S t          j	        dk    rmt           j                             dd	¦  «        }|r/t          t          |d
¦  «                             ¦   «         ¦  «        S t          t          ¦   «         d¦  «        S |                      dd	¦  «        }|st          |dd¦  «        }t          |d
¦  «        S )zÓGet the config directory for Jupyter data files for this platform and user.

    These are non-transient, non-configuration files.

    Returns JUPYTER_DATA_DIR if defined, else a platform-appropriate path.
    ÚJUPYTER_DATA_DIRFrW   r
   ÚLibraryr   r	   ÚAPPDATANr   ÚdataÚXDG_DATA_HOMEz.localÚshare)r#   r$   rK   r(   rY   Úuser_data_dirr[   r.   rG   Úplatformr   r   r,   r\   r_   )r]   ÚhomeÚappdataÚxdgs       r   Újupyter_data_dirrl   ¤   s$  € õ Œ*€Cà
‡w‚wÐ!Ñ"Ô"ð 'ØÐ%Ô&Ð&åÑÔð DÝÔ)­'¸UÐCÑCÔCÐCå‰>Œ>€Då
„|�xÒÐÝ•4˜˜i¨Ñ3Ô3Ñ4Ô4Ð4å
„|�wÒÐÝ”*—.’. ¨DÑ1Ô1ˆØð 	;Ý•t˜G YÑ/Ô/×7Ò7Ñ9Ô9Ñ:Ô:Ð:ÝÕ'Ñ)Ô)¨6Ñ2Ô2Ð2ð �'Š'�/ 4Ñ
(Ô
(€CØð -Ý�D˜( GÑ,Ô,ˆÝ��iÑ Ô Ð r   c                 óŒ   — t           j        } |                      d¦  «        r| d         S t          t	          ¦   «         d¦  «        S )zßReturn the runtime dir for transient jupyter files.

    Returns JUPYTER_RUNTIME_DIR if defined.

    The default is now (data_dir)/runtime on all platforms;
    we no longer use XDG_RUNTIME_DIR after various problems.
    ÚJUPYTER_RUNTIME_DIRÚruntime)r#   r$   rK   r\   rl   )r]   s    r   Újupyter_runtime_dirrp   Å   sC   € õ Œ*€Cà
‡w‚wÐ$Ñ%Ô%ð *ØÐ(Ô)Ð)åÕ!Ñ#Ô# YÑ/Ô/Ð/r   ÚJUPYTER_USE_PROGRAMDATAÚ_use_programdataz
str | NoneÚ_win_programdataÚntÚPROGRAMDATArf   T)rX   Ú	multipathz/usr/local/share/jupyterz/usr/share/jupyterú	list[str]ÚENV_JUPYTER_PATHÚsubdirsc                 óp  ‡ — g }t           j                             d¦  «        rL|                     d„ t           j        d                              t           j        ¦  «        D ¦   «         ¦  «         t          ¦   «         g}t          j        rmt          t          d¦  «        rt          j
        ¦   «         nt          j        }|r7t          t          |dd¦  «        ¦  «        }||vr|                     |¦  «         t          t           k    rt          }nd„ t          D ¦   «         }t#          ¦   «         r+|                     |¦  «         |                     |¦  «         n*|                     |¦  «         |                     |¦  «         t           D ]}||vr|                     |¦  «         Œ‰ rˆ fd„|D ¦   «         }|S )ay  Return a list of directories to search for data files.

    There are four sources of paths to search:

    - $JUPYTER_PATH environment variable (always highest priority)
    - user directories (e.g. ~/.local/share/jupyter)
    - environment directories (e.g. {sys.prefix}/share/jupyter)
    - system-wide paths (e.g. /usr/local/share/jupyter)

    JUPYTER_PATH environment variable has highest priority, if defined,
    and is purely additive.

    If the JUPYTER_PREFER_ENV_PATH environment variable is set, the environment-level
    directories will have priority over user-level directories.
    You can also set JUPYTER_PREFER_ENV_PATH=0 to explicitly prefer user directories.
    If Jupyter detects that you are in a virtualenv or conda environment,
    environment paths are also preferred to user paths,
    otherwise user paths are preferred to environment paths.

    If the Python site.ENABLE_USER_SITE variable is True, we also add the
    appropriate Python user site subdirectory to the user-level directories.

    Finally, system-wide directories, such as `/usr/local/share/jupyter` are searched.

    If ``*subdirs`` are given, that subdirectory will be added to each element.


    .. versionchanged:: 5.8

        On Windows, %PROGRAMDATA% will be used as a system-wide path only if
        the JUPYTER_USE_PROGRAMDATA env is set.
        By default, there is no default system-wide path on Windows and the env path
        is used instead.

    Examples:

    >>> jupyter_path()
    ['~/.local/jupyter', '/usr/local/share/jupyter']
    >>> jupyter_path('kernels')
    ['~/.local/jupyter/kernels', '/usr/local/share/jupyter/kernels']
    ÚJUPYTER_PATHc              3  óT   K  — | ]#}|                      t          j        ¦  «        V — Œ$d S r   ©Úrstripr#   Úsep©Ú.0r?   s     r   ú	<genexpr>zjupyter_path.<locals>.<genexpr>%  s0   è è € Ð\Ð\¨!�Q—X’X�bœfÑ%Ô%Ð\Ð\Ð\Ð\Ð\Ð\r   Úgetuserbaserf   r   c                ó$   — g | ]}|t           v¯|‘ŒS r   )ÚSYSTEM_JUPYTER_PATHr€   s     r   ú
<listcomp>z jupyter_path.<locals>.<listcomp>:  s#   € ÐKÐKÐK�Q¨aÕ7JÐ.JÐ.JˆqÐ.JÐ.JÐ.Jr   c                ó*   •— g | ]}t          |g‰¢R Ž ‘ŒS r   )r\   )r�   r?   ry   s     €r   r†   z jupyter_path.<locals>.<listcomp>J  s)   ø€ Ð3Ð3Ð3¨•�qÐ#˜7Ð#Ð#Ð#Ð3Ð3Ð3r   )r#   r$   rK   ÚextendÚsplitÚpathseprl   ÚsiteÚENABLE_USER_SITEr8   rƒ   Ú	USER_BASEr   r   Úappendrx   r…   rL   )ry   ÚpathsÚuserÚuserbaseÚuserdirr]   Ú_paths   `      r   Újupyter_pathr”   ö   s¶  ø€ ðV €Eõ 
„z‡~‚~�nÑ%Ô%ð ]Ø�ŠÐ\Ð\­r¬z¸.Ô/I×/OÒ/OÕPRÔPZÑ/[Ô/[Ð\Ñ\Ô\Ñ\Ô\Ð\õ ÑÔÐ€DÝÔð 	%õ *1µ°}Ñ)EÔ)EÐY•4Ô#Ñ%Ô%Ð%Í4Ì>ˆàð 	%Ý�$˜x¨°)Ñ<Ô<Ñ=Ô=ˆGØ˜dÐ"Ð"Ø—’˜GÑ$Ô$Ð$õ
 Õ.Ò.Ð.ÝˆˆàKÐKÕ*ÐKÑKÔKˆå#Ñ%Ô%ð Ø�Š�SÑÔÐØ�Š�TÑÔÐÐà�Š�TÑÔÐØ�Š�SÑÔÐõ %ð  ð  ˆØ˜ÐÐØ�LŠL˜ÑÔÐøð ð 4Ø3Ð3Ð3Ð3¨UÐ3Ñ3Ô3ˆØ€Lr   ÚetcÚENV_CONFIG_PATHz/usr/local/etc/jupyterz/etc/jupyterc                 ó¸  — t           j                             d¦  «        rt          ¦   «         gS g } t           j                             d¦  «        rL|                      d„ t           j        d                              t           j        ¦  «        D ¦   «         ¦  «         t          ¦   «         g}t          j        rmt          t          d¦  «        rt          j
        ¦   «         nt          j        }|r7t          t          |dd¦  «        ¦  «        }||vr|                     |¦  «         t          t           k    rt          }nd„ t          D ¦   «         }t#          ¦   «         r+|                      |¦  «         |                      |¦  «         n*|                      |¦  «         |                      |¦  «         t          t           k    r|                      t           ¦  «         | S )a+  Return the search path for Jupyter config files as a list.

    If the JUPYTER_PREFER_ENV_PATH environment variable is set, the
    environment-level directories will have priority over user-level
    directories.

    If the Python site.ENABLE_USER_SITE variable is True, we also add the
    appropriate Python user site subdirectory to the user-level directories.

    Finally, system-wide directories such as `/usr/local/etc/jupyter` are searched.


    .. versionchanged:: 5.8

        On Windows, %PROGRAMDATA% will be used as a system-wide path only if
        the JUPYTER_USE_PROGRAMDATA env is set.
        By default, there is no system-wide config path on Windows.

    Examples:

    >>> jupyter_config_path()
    ['~/.jupyter', '~/.local/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter']

    rU   ÚJUPYTER_CONFIG_PATHc              3  óT   K  — | ]#}|                      t          j        ¦  «        V — Œ$d S r   r}   r€   s     r   r‚   z&jupyter_config_path.<locals>.<genexpr>ˆ  s0   è è € ÐcÐc¨!�Q—X’X�bœfÑ%Ô%ÐcÐcÐcÐcÐcÐcr   rƒ   r•   r   c                ó$   — g | ]}|t           v¯|‘ŒS r   )ÚSYSTEM_CONFIG_PATHr€   s     r   r†   z'jupyter_config_path.<locals>.<listcomp>�  s#   € ÐIÐIÐI�Q¨QÕ6HÐ-HÐ-HˆqÐ-HÐ-HÐ-Hr   )r#   r$   rK   r_   rˆ   r‰   rŠ   r‹   rŒ   r8   rƒ   r�   r   r   rŽ   r–   r›   rL   )r�   r�   r‘   r’   r]   s        r   Újupyter_config_pathrœ   g  sª  € õ2 
„z‡~‚~Ð)Ñ*Ô*ð &å"Ñ$Ô$Ð%Ð%à€Eõ 
„z‡~‚~Ð+Ñ,Ô,ð dØ�ŠÐcÐc­r¬zÐ:OÔ/P×/VÒ/VÕWYÔWaÑ/bÔ/bÐcÑcÔcÑcÔcÐcõ Ñ Ô Ð!€DÝÔð 	%õ *1µ°}Ñ)EÔ)EÐY•4Ô#Ñ%Ô%Ð%Í4Ì>ˆàð 	%Ý�$˜x¨°	Ñ:Ô:Ñ;Ô;ˆGØ˜dÐ"Ð"Ø—’˜GÑ$Ô$Ð$õ
 Õ,Ò,Ð,ÝˆˆàIÐI�/ÐIÑIÔIˆå#Ñ%Ô%ð Ø�Š�SÑÔÐØ�Š�TÑÔÐÐà�Š�TÑÔÐØ�Š�SÑÔÐõ Õ,Ò,Ð,Ø�ŠÕ'Ñ(Ô(Ð(Ø€Lr   c                óT   — 	 t          j        | ¦  «         n# t          $ r Y dS w xY wdS )zcReplacement for `os.path.exists` which works for host mapped volumes
    on Windows containers
    FT)r#   Úlstatr<   )r0   s    r   r3   r3   ¬  s=   € ðÝ
Œ�‰ŒˆˆøÝð ð ð Øˆuˆuðøøøàˆ4s   ‚ —
%¤%Úabs_pathú
str | PathÚstat_resú
Any | Nonec                ó~  — t          | ¦  «        } | j                             d¦  «        rdS |€Q	 t          | ¦  «                             ¦   «         }n.# t          $ r!}|j        t
          j        k    rY d}~dS ‚ d}~ww xY w	 |j        t          j        z  rdS n&# t          $ r t          j        dd¬¦  «         Y nw xY wdS )áÖ  Is a file hidden?

    This only checks the file itself; it should be called in combination with
    checking the directory containing the file.

    Use is_hidden() instead to check the file and its parent directories.

    Parameters
    ----------
    abs_path : unicode
        The absolute path to check.
    stat_res : os.stat_result, optional
        The result of calling stat() on abs_path. If not passed, this function
        will call stat() internally.
    ú.TNFzThidden files are not detectable on this system, so no file will be marked as hidden.é   ©Ú
stacklevel)r   r   rJ   r9   r<   ÚerrnoÚENOENTÚst_file_attributesÚFILE_ATTRIBUTE_HIDDENÚAttributeErrorÚwarningsÚwarn©rŸ   r¡   Úes      r   Úis_file_hidden_winr²   ·  s  € õ  �H‰~Œ~€HØ„}×Ò Ñ$Ô$ð ØˆtàÐð	Ý˜H‘~”~×*Ò*Ñ,Ô,ˆHˆHøÝð 	ð 	ð 	ØŒw�%œ,Ò&Ð&Ø�u�u�u�u�uØøøøøð	øøøð

àÔ'ÝÔ(ñ)ð	ð �4ð		øõ
 ð 
ð 
ð 
õ 	ŒØbØð	
ñ 	
ô 	
ð 	
ð 	
ð 	
ð	
øøøð ˆ5s/   ¯!A Á
A<ÁA7Á6A7Á7A<Â B Â B:Â9B:c                óÞ  — t          | ¦  «        } | j                             d¦  «        rdS |�t          j        |j        ¦  «        rD	 |                      ¦   «         }n.# t          $ r!}|j        t          j        k    rY d}~dS ‚ d}~ww xY wt          j	        |j        ¦  «        r.t          j        | t          j        t          j        z  ¦  «        sdS t          |dd¦  «        t          z  rdS dS )r¤   r¥   TNFÚst_flagsr   )r   r   rJ   r9   ÚS_ISLNKÚst_moder<   r©   rª   ÚS_ISDIRr#   r=   ÚX_OKÚR_OKÚgetattrr   r°   s      r   Úis_file_hidden_posixr»   å  sô   € õ  �H‰~Œ~€HØ„}×Ò Ñ$Ô$ð ØˆtàÐ�4œ<¨Ô(8Ñ9Ô9Ðð	Ø—}’}‘”ˆHˆHøÝð 	ð 	ð 	ØŒw�%œ,Ò&Ð&Ø�u�u�u�u�uØøøøøð	øøøõ „|�HÔ$Ñ%Ô%ð åŒy˜¥2¤7­R¬WÑ#4Ñ5Ô5ð 	Ø�4õ ˆx˜ QÑ'Ô'­)Ñ3ð Øˆtàˆ5s   ÁA Á
BÁ'BÂBÂBÚ Úabs_rootc                ó`  — t          t          j                             | ¦  «        ¦  «        } |r-t          t          j                             |¦  «        ¦  «        }nt	          | j        ¦  «        d         }| |k    rdS |                      ¦   «         sd| ›d�}t          |¦  «        ‚|                     ¦   «         sd|›d�}t          |¦  «        ‚|                      |¦  «        sd| ›d|›d�}t          |¦  «        ‚t          | ¦  «        rd	S |  
                    |¦  «        }t          d
„ |j        D ¦   «         ¦  «        rd	S | j        D ]c}|                     ¦   «         sŒ||k    r nE	 |                     ¦   «         }n# t          $ r Y  d	S w xY wt!          |dd¦  «        t"          z  r d	S ŒddS )aì  Is a file hidden or contained in a hidden directory?

    This will start with the rightmost path element and work backwards to the
    given root to see if a path is hidden or in a hidden directory. Hidden is
    determined by either name starting with '.' or the UF_HIDDEN flag as
    reported by stat.

    If abs_path is the same directory as abs_root, it will be visible even if
    that is a hidden folder. This only checks the visibility of files
    and directories *within* abs_root.

    Parameters
    ----------
    abs_path : str or Path
        The absolute path to check for hidden directories.
    abs_root : str or Path
        The absolute path of the root directory in which hidden directories
        should be checked for.
    éÿÿÿÿFz	abs_path=z, is not absolute. abs_path must be absolute.z	abs_root=z, is not absolute. abs_root must be absolute.z# is not a subdirectory of abs_root=z#. abs_path must be within abs_root.Tc              3  ó@   K  — | ]}|                      d ¦  «        V — ŒdS )r¥   N)rJ   )r�   Úparts     r   r‚   zis_hidden.<locals>.<genexpr>C  s.   è è € Ð
@Ð
@ Dˆ4�?Š?˜3ÑÔÐ
@Ð
@Ð
@Ð
@Ð
@Ð
@r   r´   r   )r   r#   r0   ÚnormpathÚlistÚparentsÚis_absoluteÚ
ValueErrorÚis_relative_toÚis_file_hiddenÚrelative_toÚanyÚpartsr3   rž   r<   rº   r   )rŸ   r½   Ú_msgÚrelative_pathr4   r@   s         r   Ú	is_hiddenrÎ     sþ  € õ( •B”G×$Ò$ XÑ.Ô.Ñ/Ô/€HØð .Ý�œ×(Ò(¨Ñ2Ô2Ñ3Ô3ˆˆå˜Ô(Ñ)Ô)¨"Ô-ˆà�8ÒÐàˆuð ×ÒÑ!Ô!ð ØI�(ÐIÐIÐIˆÝ˜ÑÔÐØ×ÒÑ!Ô!ð ØI�(ÐIÐIÐIˆÝ˜ÑÔÐØ×"Ò" 8Ñ,Ô,ð àbˆxÐbÐb°HÐbÐbÐbð 	õ ˜ÑÔÐå�hÑÔð Øˆtà×(Ò(¨Ñ2Ô2€MÝ
Ð
@Ð
@¨MÔ,?Ð
@Ñ
@Ô
@Ñ@Ô@ð Øˆtð Ô"ð ð ˆØ�}Š}‰Œð 	ØØ�XÒÐØˆEð	à—’‘”ˆBˆBøÝð 	ð 	ð 	Ø�4�4�4ð	øøøå�2�z 1Ñ%Ô%­	Ñ1ð 	Ø�4�4ð	ð ˆ5s   Å*E?Å?
FÆFÚfnamec                ó`  — 	 ddl }n# t          $ r t          | ¦  «        cY S w xY wddl}ddl}|                     |j        ¦  «        }|                     d|                     |j	        ¦  «        ¦  «        \  }}}| 
                    | |j        ¦  «        }|                     ¦   «         }	|	                     |j        |j        |j        z  |j        z  |¦  «         |	                     |j        |j        |¦  «         |                     d|	d¦  «         |                     | |j        |¦  «         dS )a‡  Secure a windows file to read-only access for the user.
    Follows guidance from win32 library creator:
    http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html

    This method should be executed against an already generated file which
    has no secrets written to it yet.

    Parameters
    ----------

    fname : unicode
        The path to the file to secure
    r   Nr¼   é   )Úwin32apiÚImportErrorÚ#_win32_restrict_file_to_user_ctypesÚntsecurityconÚwin32securityÚCreateWellKnownSidÚWinBuiltinAdministratorsSidÚLookupAccountNameÚGetUserNameExÚNameSamCompatibleÚGetFileSecurityÚDACL_SECURITY_INFORMATIONÚACLÚAddAccessAllowedAceÚACL_REVISIONÚFILE_GENERIC_READÚFILE_GENERIC_WRITEÚDELETEÚFILE_ALL_ACCESSÚSetSecurityDescriptorDaclÚSetFileSecurity)
rÏ   rÒ   ÚconrÖ   Úadminsr�   Ú_domainÚ_typeÚsdÚdacls
             r   Úwin32_restrict_file_to_userrí   X  s_  € ð:ØˆˆˆˆøÝð :ð :ð :Ý2°5Ñ9Ô9Ð9Ð9Ð9ð:øøøð  ÐÐÐØÐÐÐð ×-Ò-¨mÔ.WÑXÔX€FØ(×:Ò:Ø
ˆH×"Ò" 8Ô#=Ñ>Ô>ñô Ñ€Dˆ'�5ð 
×	&Ò	& u¨mÔ.UÑ	VÔ	V€Bà×ÒÑÔ€Dà×ÒØÔ"ØÔ Ô 6Ñ6¸¼ÑCØñô ð ð
 	×Ò˜]Ô7¸Ô9LÈfÑUÔUÐUà× Ò   D¨!Ñ,Ô,Ð,Ø×!Ò! %¨Ô)PÐRTÑUÔUÐUØˆ4s   ‚ ‡#¢#c                ó6  ‡%‡&‡'‡(‡)‡*‡+‡,‡-— ddl Š+ddl mŠ- ‰+                     dd¬¦  «        Š*‰+                     dd¬¦  «        Š,d}d	}d
}dŠ%dŠ&dŠ'd}d}d}d}d}d}	d}
d}d}d
}d}d}||z  dz  }||	z  |z  |
z  |z  }||z  |z  |z  |z  |z  } G ˆ-fd„d‰+j        ¦  «        }‰+j        Š)‰+                     |¦  «        Š(‰+                     ‰-j        ¦  «        }d;ˆ+fd„}|‰,j        _        ‰-j	        ‰,j        _
        ‰+j        ‰-j        ‰-j        f‰,j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰-j        ‰)‰)‰-j        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰-j        ‰-j        ‰)‰-j        ‰-j        ‰-j        ‰-j        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰(‰-j        ‰-j        ‰)f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        |‰-j	        ‰(‰-j	        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰-j        ‰-j        |‰-j        ‰-j        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰-j        ‰-j        |f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ||‰-j        ‰(‰-j        ‰(‰-j        ‰)‰-j        ‰)‰-j        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ||‰-j        f‰*j        _        |‰*j        _        ‰-j	        ‰*j        _
        ‰(‰-j        ‰-j        f‰*j        _        d<ˆ&ˆ*ˆ+ˆ-fd!„}d=ˆ'ˆ+ˆ,fd#„}d>ˆ&ˆ*ˆ+ˆ-fd&„}d?ˆ*fd+„}d@ˆ&ˆ*ˆ+ˆ-fd.„}dAˆ*fd0„}dBˆ*fd4„}dCˆ&ˆ(ˆ)ˆ*ˆ+ˆ-fd6„}dDˆ&ˆ*ˆ+ˆ-fd8„}dEˆ%ˆ(ˆ*ˆ+fd9„} ||¦  «        }  |d: ||¦  «        ¦  «        d         }! |¦   «         }" ||"‰%|| ¦  «          ||"‰%||z  |z  |!¦  «          || |¦  «        }# ||#¦  «        }$ ||$d|"d¦  «          ||$¦  «        }# || ||#¦  «         dS )Faˆ  Secure a windows file to read-only access for the user.

    Follows guidance from win32 library creator:
    http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html

    This method should be executed against an already generated file which
    has no secrets written to it yet.

    Parameters
    ----------

    fname : unicode
        The path to the file to secure
    r   N©ÚwintypesÚadvapi32T)Úuse_last_errorÚsecur32r¦   é   é   éz   éê   i   i   i   i   rÑ   é   é€   é   é   iÿ  c                  ód   •— e Zd Zd” j        fd” j        fd” j        fd” j        fd” j        fgZdS )ú0_win32_restrict_file_to_user_ctypes.<locals>.ACLÚAclRevisionÚSbz1ÚAclSizeÚAceCountÚSbz2N)Ú__name__Ú
__module__Ú__qualname__ÚBYTEÚWORDÚ_fields_rï   s   €r   rÞ   rý   ¹  sH   ø€ € € € € à˜HœMÐ*Ø�X”]Ð#Ø˜œÐ&Ø˜œÐ'Ø�X”]Ð#ð
ˆˆˆr   rÞ   ÚresultÚintÚfuncr   Úargsr   c                óZ   •— | s'‰                      ‰                     ¦   «         ¦  «        ‚|S r   )ÚWinErrorÚget_last_error)r	  r  r  Úctypess      €r   Ú_nonzero_successz=_win32_restrict_file_to_user_ctypes.<locals>._nonzero_successÆ  s.   ø€ Øð 	;Ø—/’/ &×"7Ò"7Ñ"9Ô"9Ñ:Ô:Ð:Øˆr   ÚWellKnownSidTypec           	     óˆ  •—  ‰j         dz  ¦   «         }‰                     ¦   «         }	 ‰                     | d |‰                     |¦  «        ¦  «         ne# t          $ rX}|j        ‰k    r‚  ‰j         |j        z  ¦   «         }‰                     | d |‰                     |¦  «        ¦  «         Y d }~nd }~ww xY w|d d …         S )NrÑ   )Úc_charÚDWORDr×   Úbyrefr<   ÚwinerrorÚvalue)r  ÚpSidÚcbSidr±   ÚERROR_INSUFFICIENT_BUFFERrñ   r  rð   s       €€€€r   r×   z?_win32_restrict_file_to_user_ctypes.<locals>.CreateWellKnownSid,  sç   ø€ à!�” Ñ!Ñ$Ô$ˆØ—’Ñ Ô ˆð	[Ø×'Ò'Ð(8¸$ÀÀfÇlÂlÐSXÑFYÔFYÑZÔZÐZÐZøÝð 	[ð 	[ð 	[ØŒzÐ6Ò6Ð6ØØ/�F”M E¤KÑ/Ñ2Ô2ˆDØ×'Ò'Ð(8¸$ÀÀfÇlÂlÐSXÑFYÔFYÑZÔZÐZÐZÐZÐZÐZÐZøøøøð		[øøøð
 �A�A�AŒwˆs   ©+A Á
B7ÁAB2Â2B7Ú
NameFormatc                ób  •— ‰                      ‰                     d¦  «        ¦  «        }	 ‰                     | d |¦  «         n## t          $ r}|j        ‰k    r‚ Y d }~nd }~ww xY w|j        j        sd S ‰                     |j        j        ¦  «        }‰                     | ||¦  «         |j        S ©Nr   )ÚpointerÚc_ulongÚGetUserNameExWr<   r  Úcontentsr  Úcreate_unicode_buffer)r  ÚnSizer±   ÚlpNameBufferÚERROR_MORE_DATAr  ró   s       €€€r   rÚ   z:_win32_restrict_file_to_user_ctypes.<locals>.GetUserNameEx9  sÏ   ø€ ð —’˜vŸ~š~¨aÑ0Ô0Ñ1Ô1ˆð	Ø×"Ò" :¨t°UÑ;Ô;Ð;Ð;øÝð 	ð 	ð 	ØŒz˜_Ò,Ð,Øð -Ð,Ð,Ð,Ð,øøøøð	øøøð Œ~Ô#ð 	Ø�4Ø×3Ò3°E´NÔ4HÑIÔIˆØ×Ò˜z¨<¸Ñ?Ô?Ð?ØÔ!Ð!s   «A Á
A#ÁAÁA#ÚlpSystemNameÚlpAccountNamec                ó4  •— ‰                      d¦  «        }‰                      d¦  «        }‰                      d¦  «        }	 ‰                     | |d ‰                     |¦  «        d ‰                     |¦  «        ‰                     |¦  «        ¦  «         n## t          $ r}|j        ‰
k    r‚ Y d }~nd }~ww xY w‰                     d|j        ¦  «        }‰                     ‰                     |¦  «        ‰j	        ¦  «        }‰                     d|j        dz   ¦  «        }‰                     | ||‰                     |¦  «        |‰                     |¦  «        ‰                     |¦  «        ¦  «        }	|	s‰ 
                    ¦   «         ‚||j        |j        fS )Nr   r¼   rÑ   )r  ÚLookupAccountNameWr  r<   r  r#  r  Úcastr  ÚLPVOIDr  )r'  r(  r  ÚcchReferencedDomainNameÚpeUser±   ÚSidr  ÚlpReferencedDomainNameÚsuccessr  rñ   r  rð   s             €€€€r   rÙ   z>_win32_restrict_file_to_user_ctypes.<locals>.LookupAccountNameH  s®  ø€ ð —’˜qÑ!Ô!ˆØ"*§.¢.°Ñ"3Ô"3ÐØ—’˜qÑ!Ô!ˆð	Ø×'Ò'ØØØØ—’˜UÑ#Ô#ØØ—’Ð4Ñ5Ô5Ø—’˜UÑ#Ô#ñô ð ð øõ ð 	ð 	ð 	ØŒzÐ6Ò6Ð6Øð 7Ð6Ð6Ð6Ð6øøøøð	øøøð ×*Ò*¨2¨u¬{Ñ;Ô;ˆØ�{Š{˜6Ÿ>š>¨#Ñ.Ô.°´Ñ@Ô@ˆØ!'×!=Ò!=¸bÐBYÔB_ÐbcÑBcÑ!dÔ!dÐØ×-Ò-ØØØØ�LŠL˜ÑÔØ"Ø�LŠLÐ0Ñ1Ô1Ø�LŠL˜ÑÔñ
ô 
ˆð ð 	$Ø—/’/Ñ#Ô#Ð#ØÐ+Ô1°5´;Ð>Ð>s   ÁAB Â
B7Â!B2Â2B7ÚpAclÚdwAceRevisionÚ
AccessMaskr  c                ó8   •— ‰                      | |||¦  «         d S r   )rß   )r2  r3  r4  r  rñ   s       €r   rß   z@_win32_restrict_file_to_user_ctypes.<locals>.AddAccessAllowedAcek  s%   ø€ ð 	×$Ò$ T¨=¸*ÀdÑKÔKÐKÐKÐKr   Ú
lpFileNameÚRequestedInformationc           	     ól  •— ‰                      d¦  «        }	 ‰                     | |d d‰                     |¦  «        ¦  «         n## t          $ r}|j        ‰k    r‚ Y d }~nd }~ww xY w|j        sd S  ‰j        |j        z  ¦   «         }‰                     | |||‰                     |¦  «        ¦  «         |S r  )r  ÚGetFileSecurityWr  r<   r  r  r  )	r6  r7  ÚnLengthr±   ÚpSecurityDescriptorr  rñ   r  rð   s	        €€€€r   rÜ   z<_win32_restrict_file_to_user_ctypes.<locals>.GetFileSecurityp  s÷   ø€ à—.’. Ñ#Ô#ˆð
	Ø×%Ò%ØØ$ØØØ—’˜WÑ%Ô%ñô ð ð øõ ð 	ð 	ð 	ØŒzÐ6Ò6Ð6Øð 7Ð6Ð6Ð6Ð6øøøøð	øøøð Œ}ð 	Ø�4Ø<˜xœ}¨w¬}Ñ<Ñ?Ô?ÐØ×!Ò!ØØ ØØØ�LŠL˜Ñ!Ô!ñ	
ô 	
ð 	
ð #Ð"s   ˜,A Á
A%ÁA Á A%r;  c                ó6   •— ‰                      | ||¦  «         d S r   )ÚSetFileSecurityW)r6  r7  r;  rñ   s      €r   ræ   z<_win32_restrict_file_to_user_ctypes.<locals>.SetFileSecurityŠ  s%   ø€ ð 	×!Ò! *Ð.BÐDWÑXÔXÐXÐXÐXr   ÚbDaclPresentÚpDaclÚbDaclDefaultedc                ó8   •— ‰                      | |||¦  «         d S r   )rå   )r;  r>  r?  r@  rñ   s       €r   rå   zF_win32_restrict_file_to_user_ctypes.<locals>.SetSecurityDescriptorDacl�  s'   ø€ ð 	×*Ò*Ð+>ÀÈeÐUcÑdÔdÐdÐdÐdr   ÚpSelfRelativeSecurityDescriptorc                ó´  •— d }‰                      d¦  «        }d }‰                      d¦  «        }d }‰                      d¦  «        }d }‰                      d¦  «        }d }	‰                      d¦  «        }
	 ‰                     | |‰                     |¦  «        |‰                     |¦  «        |‰                     |¦  «        |‰                     |¦  «        |	‰                     |
¦  «        ¦  «         n## t          $ r}|j        ‰k    r‚ Y d }~nd }~ww xY w ‰j        |j        z  ¦   «         } ‰j        |j        z  ¦   «         }‰                     |‰¦  «        j        } ‰j        |j        z  ¦   «         }‰                     |‰¦  «        j        } ‰j        |j        z  ¦   «         }‰                     |‰¦  «        } ‰j        |
j        z  ¦   «         }‰                     |‰¦  «        }	‰                     | |‰                     |¦  «        |‰                     |¦  «        |‰                     |¦  «        |||	‰                     |
¦  «        ¦  «         |S r  )	r  ÚMakeAbsoluteSDr  r<   r  r  r  r+  r"  )rB  ÚpAbsoluteSecurityDescriptorÚ"lpdwAbsoluteSecurityDescriptorSizer?  ÚlpdwDaclSizeÚpSaclÚlpdwSaclSizeÚpOwnerÚlpdwOwnerSizeÚpPrimaryGroupÚlpdwPrimaryGroupSizer±   Ú	pDaclDataÚ	pSaclDataÚ
pOwnerDataÚpPrimaryGroupDatar  ÚPACLÚPSIDrñ   r  rð   s                   €€€€€€r   rD  z;_win32_restrict_file_to_user_ctypes.<locals>.MakeAbsoluteSD–  sz  ø€ ð '+Ð#Ø-5¯^ª^¸AÑ->Ô->Ð*ØˆØ—~’~ aÑ(Ô(ˆØˆØ—~’~ aÑ(Ô(ˆØˆØ Ÿš qÑ)Ô)ˆØˆØ'Ÿ~š~¨aÑ0Ô0Ðð	Ø×#Ò#Ø/Ø+Ø—’Ð?Ñ@Ô@ØØ—’˜\Ñ*Ô*ØØ—’˜\Ñ*Ô*ØØ—’˜]Ñ+Ô+ØØ—’Ð1Ñ2Ô2ñô ð ð øõ ð 	ð 	ð 	ØŒzÐ6Ò6Ð6Øð 7Ð6Ð6Ð6Ð6øøøøð	øøøð (` x¤}Ð7YÔ7_Ñ'_Ñ&bÔ&bÐ#Ø7�X”] \Ô%7Ñ7Ñ:Ô:ˆ	Ø—’˜I tÑ,Ô,Ô5ˆØ7�X”] \Ô%7Ñ7Ñ:Ô:ˆ	Ø—’˜I tÑ,Ô,Ô5ˆØ9�h”m mÔ&9Ñ9Ñ<Ô<ˆ
Ø—’˜Z¨Ñ.Ô.ˆØG˜Xœ]Ð-AÔ-GÑGÑJÔJÐØŸšÐ$5°tÑ<Ô<ˆØ×ÒØ+Ø'Ø�LŠLÐ;Ñ<Ô<ØØ�LŠL˜Ñ&Ô&ØØ�LŠL˜Ñ&Ô&ØØØØ�LŠLÐ-Ñ.Ô.ñ	
ô 	
ð 	
ð +Ð*s   Á6A>C5 Ã5
DÃ?DÄDrE  c                óV  •— d }‰                      d¦  «        }	 ‰                     | |‰                     |¦  «        ¦  «         n## t          $ r}|j        ‰k    r‚ Y d }~nd }~ww xY w ‰j        |j        z  ¦   «         }‰                     | |‰                     |¦  «        ¦  «         |S r  )r  ÚMakeSelfRelativeSDr  r<   r  r  r  )rE  rB  ÚlpdwBufferLengthr±   r  rñ   r  rð   s       €€€€r   rU  z?_win32_restrict_file_to_user_ctypes.<locals>.MakeSelfRelativeSDÌ  sê   ø€ ð +/Ð'Ø#Ÿ>š>¨!Ñ,Ô,Ðð	Ø×'Ò'Ø+Ø/Ø—’Ð-Ñ.Ô.ñô ð ð øõ
 ð 	ð 	ð 	ØŒzÐ6Ò6Ð6Øð 7Ð6Ð6Ð6Ð6øøøøð	øøøð ,R¨8¬=Ð;KÔ;QÑ+QÑ*TÔ*TÐ'Ø×#Ò#Ø'Ø+Ø�LŠLÐ)Ñ*Ô*ñ	
ô 	
ð 	
ð
 /Ð.s   š*A Á
A%ÁA Á A%c                 óš   •— d} ‰                      | ¦  «        }‰                     |‰¦  «        j        }‰                     || ‰¦  «         |S )Niÿ  )Úcreate_string_bufferr+  r"  ÚInitializeAcl)Ú
nAclLengthÚacl_datar2  rà   rR  rñ   r  s      €€€€r   ÚNewAclz3_win32_restrict_file_to_user_ctypes.<locals>.NewAclâ  sN   ø€ àˆ
Ø×.Ò.¨zÑ:Ô:ˆØ�{Š{˜8 TÑ*Ô*Ô3ˆØ×Ò˜t Z°Ñ>Ô>Ð>Øˆr   r¼   )r	  r
  r  r   r  r   r   r   )r  r   r   r   )r  r   r   r   )r'  r   r(  r   r   r   )
r2  r   r3  r   r4  r   r  r   r   r   )r6  r   r7  r   r   r   )r6  r   r7  r   r;  r   r   r   )
r;  r   r>  r   r?  r   r@  r   r   r   )rB  r   r   r   )rE  r   r   r   )r   r   )r  rð   ÚWinDLLÚ	StructureÚc_void_pÚPOINTERr  r!  ÚerrcheckÚBOOLÚrestypeÚc_intÚLPWSTRÚPULONGÚargtypesr×   r  ÚPDWORDr*  ÚLPDWORDrß   rå   r9  ÚLPCWSTRr=  rD  rU  rY  ).rÏ   rÛ   rØ   rÝ   ÚSYNCHRONIZErã   ÚSTANDARD_RIGHTS_REQUIREDÚSTANDARD_RIGHTS_READÚSTANDARD_RIGHTS_WRITEÚFILE_READ_DATAÚFILE_READ_EAÚFILE_READ_ATTRIBUTESÚFILE_WRITE_DATAÚFILE_APPEND_DATAÚFILE_WRITE_EAÚFILE_WRITE_ATTRIBUTESrä   rá   râ   rÞ   ÚPSECURITY_DESCRIPTORr  r×   rÚ   rÙ   rß   rÜ   ræ   rå   rD  rU  r\  Ú	SidAdminsÚSidUserÚAclÚSelfRelativeSDÚ
AbsoluteSDrà   r  r&  rR  rS  rñ   r  ró   rð   s.                                        @@@@@@@@@r   rÔ   rÔ   „  sŽ  øøøøøøøøø€ ð €M€M€MØÐÐÐÐÐà�}Š}˜Z¸ˆ}Ñ=Ô=€HØ�mŠm˜I°dˆmÑ;Ô;€GàÐØ"$ÐØ !ÐØ€LØ #ÐØ€Oà€KØ€FØ&ÐØ"ÐØ#ÐØ€NØ€LØÐØ€OØÐØ€MØÐØ.°Ñ<¸uÑD€Oà˜~Ñ-Ð0DÑDÀ|ÑSÐVaÑað ð 	Ø
ñ	à
ñ	 ð ñ	ð ñ		ð
 ñ	ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ˆfÔñ 
ô 
ð 
ð Œ?€DØ�>Š>˜#ÑÔ€DØ!Ÿ>š>¨(¬-Ñ8Ô8Ððð ð ð ð ð ð
 '7€GÔÔ#Ø%-¤]€GÔÔ"àŒØŒØŒð'€GÔÔ#ð ,<€HÔÔ(Ø*2¬-€HÔÔ'àŒØØØŒð	,€HÔÔ(ð ,<€HÔÔ(Ø*2¬-€HÔÔ'àŒØŒØØÔØŒØÔØÔð,€HÔÔ(ð -=€HÔ Ô)Ø+3¬=€HÔ Ô(àØŒØŒØð	-€HÔ Ô)ð 3C€HÔ&Ô/Ø19´€HÔ&Ô.àØŒØØŒð	3€HÔ&Ô/ð *:€HÔÔ&Ø(0¬€HÔÔ%àÔØŒØØŒØÔð*€HÔÔ&ð *:€HÔÔ&Ø(0¬€HÔÔ%àÔØŒØð*€HÔÔ&ð (8€HÔÔ$Ø&.¤m€HÔÔ#àØØÔØØÔØØÔØØÔØØÔð(€HÔÔ$ð ,<€HÔÔ(Ø*2¬-€HÔÔ'àØØÔð,€HÔÔ(ð '7€HÔÔ#Ø%-¤]€HÔÔ"àØŒØŒð'€HÔÔ#ðð ð ð ð ð ð ð ð ð"ð "ð "ð "ð "ð "ð "ð "ð!?ð !?ð !?ð !?ð !?ð !?ð !?ð !?ð !?ðFLð Lð Lð Lð Lð Lð
#ð #ð #ð #ð #ð #ð #ð #ð #ð4Yð Yð Yð Yð Yð Yðeð eð eð eð eð eð4+ð 4+ð 4+ð 4+ð 4+ð 4+ð 4+ð 4+ð 4+ð 4+ð 4+ðl/ð /ð /ð /ð /ð /ð /ð /ð /ð,ð ð ð ð ð ð ð ð ð #Ð"Ð#>Ñ?Ô?€IØÐ  M MÐ2CÑ$DÔ$DÑEÔEÀaÔH€Gà
ˆ&‰(Œ(€CØÐ˜˜\¨?¸IÑFÔFÐFØÐØØØÐ.Ñ.°Ñ7Øñ	ô ð ð %�_ UÐ,EÑFÔF€NØ� Ñ/Ô/€JØÐ˜j¨!¨S°!Ñ4Ô4Ð4Ø'Ð'¨
Ñ3Ô3€Nà€O�EÐ4°nÑEÔEÐEÐEÐEr   r
  c                óx   — t          j        t          | ¦  «                              ¦   «         j        ¦  «        dz  S )z·Retrieves the file mode corresponding to fname in a filesystem-tolerant manner.

    Parameters
    ----------

    fname : unicode
        The path to the file to get mode from

    i¿  )r9   ÚS_IMODEr   r¶   )rÏ   s    r   Úget_file_moder~  þ  s0   € õ 	Œ•T˜%‘[”[×%Ò%Ñ'Ô'Ô/Ñ0Ô0°6Ñ9ðr   ÚJUPYTER_ALLOW_INSECURE_WRITESr    )ÚtrueÚ1ÚbinaryúIterator[Any]c              #  ó  K  — |rdnd}|rdnd}t           j        t           j        z  t           j        z  }	 t	          | ¦  «                             ¦   «          n# t          $ r Y nw xY wt           j        dk    rht          rt          ¦   «          nRt          j
        | |d¦  «        }t          j        |¦  «         t           j        t           j        z  }t          | ¦  «         t          j        t          j
        | |d¦  «        ||¬¦  «        5 }t           j        dk    rPt          | ¦  «        }|dk    r;t          rt          ¦   «          n%d| › d	t          |¦  «        › d
�}t!          |¦  «        ‚|V — ddd¦  «         dS # 1 swxY w Y   dS )aD  Opens a file in the most restricted pattern available for
    writing content. This limits the file mode to `0o0600` and yields
    the resulting opened filed handle.

    Parameters
    ----------

    fname : unicode
        The path to the file to write

    binary: boolean
        Indicates that the file is binary
    ÚwbÚwNzutf-8rt   i€  )Úencodingz0Permissions assignment failed for secure file: 'z'. Got 'z' instead of '0o0600'.)r#   ÚO_CREATÚO_WRONLYÚO_TRUNCr   Úunlinkr<   r   Úallow_insecure_writesÚissue_insecure_write_warningÚopenÚcloserí   Úfdopenr~  ÚoctÚRuntimeError)	rÏ   r‚  Úmoder‡  Ú	open_flagÚfdÚfÚ	file_modeÚmsgs	            r   Úsecure_writer™    së  è è € ð Ð"ˆ4ˆ4˜s€DØÐ*ˆtˆt 7€HÝ”
�Rœ[Ñ(­2¬:Ñ5€IðÝˆU‰Œ×ÒÑÔÐÐøÝð ð ð àˆðøøøõ 
„w�$‚€Ý ð 	/õ )Ñ*Ô*Ð*Ð*õ
 ”˜ 	¨6Ñ2Ô2ˆBÝŒH�R‰LŒLˆLÝœ¥b¤jÑ0ˆIÝ'¨Ñ.Ô.Ð.å	Œ•2”7˜5 )¨VÑ4Ô4°dÀXÐ	NÑ	NÔ	Nð ÐRSÝŒ7�dŠ?ˆ?å% eÑ,Ô,ˆIØ˜FÒ"Ð"Ý(ð ,Ý0Ñ2Ô2Ð2Ð2ðHÈ5ð Hð HÝ!$ Y¡¤ðHð Hð Hð õ ' sÑ+Ô+Ð+Øˆˆˆðð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð s$   ¶!A Á
A%Á$A%ÄA%E=Å=FÆFc                 óR   — dd„} | t           _        t          j        dd	¬
¦  «         dS )z Issue an insecure write warning.r˜  r   r  r   Úkwargsr   c                ó&   — t          | ¦  «        dz   S )Nú
)r   )r˜  r  r›  s      r   Úformat_warningz4issue_insecure_write_warning.<locals>.format_warningM  s   € Ý�3‰xŒx˜$‰Ðr   z®WARNING: Insecure writes have been enabled via environment variable 'JUPYTER_ALLOW_INSECURE_WRITES'! If this is not intended, remove the variable or set its value to 'False'.r¦   r§   N)r˜  r   r  r   r›  r   r   r   )r®   Úformatwarningr¯   )rž  s    r   r�  r�  J  sM   € ðð ð ð ð ,…HÔÝ„Mð	0ð ð	ñ ô ð ð ð r   )F)r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   )r   r   )r0   r   r   r   )r   r   r   r   )ry   r   r   rw   )r   rw   r   )rŸ   r    r¡   r¢   r   r   )r¼   )rŸ   r    r½   r    r   r   )rÏ   r   r   r   )rÏ   r   r   r
  )rÏ   r   r‚  r   r   rƒ  )r   r   )EÚ__doc__Ú
__future__r   r©   r#   r‹   r9   rG   rP   r®   Úcollections.abcr   Ú
contextlibr   Úpathlibr   Útypingr   r   rY   r0   Újoinr\   rh   rH   rJ   r[   rº   r   r   r(   r.   r/   Ú__annotations__rA   rL   rS   r_   rl   rp   rr   rs   r   r$   rK   r   r…   Úsite_data_dirr‰   rŠ   rx   r”   r–   r›   Úsite_config_dirrœ   r3   r²   r»   rÈ   rÎ   rí   rÔ   r~  Úgetenvr%   rŒ  r™  r�  r   r   r   ú<module>r«     sã  ðØ Ð Ð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø €€€Ø €€€Ø 
€
€
€
Ø €€€Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð à
ŒŒ€ð „<�7ÒÐØ„L�HÒÐ S¤Z×%:Ò%:¸?Ñ%KÔ%KÐà€G€Gà€Gð ˆG�D˜+ uÑ-Ô-€	ð 
Ø 9Ð 9Ð 9Ð 9ñ 
„Ø 9ð 
Ø 8Ð 8Ð 8ñ 
„Ø 8ðSð Sð Sð Sð Sð2ð 2ð 2ð 2ð(ð (ð (ð (ð €Ð Ð Ð Ñ ð!ð !ð !ð !ð6ð ð ð ð,
ð 
ð 
ð 
ð'ð 'ð 'ð 'ð*!ð !ð !ð !ðB0ð 0ð 0ð 0ð"  ˜Ð 9Ñ:Ô:Ð Ð :Ð :Ð :Ñ :à#Ð Ð #Ð #Ð #Ñ #Ø„7ˆd‚?€?Ð'€?Ø”z—~’~ m°TÑ:Ô:Ðð ÐÑÔð 
Ø	„w�$‚€Ð/€à"˜s 4 4¨¬
°G¸YÑ#GÔ#GÑHÔHÐIÐÐà8˜lÔ8Ø˜u°ð
ñ 
ô 
ç
Š%�”
Ñ
Ô
ð 	Ðð
 
„w�$‚€àð 	NØ#( 5Ð)9¸9Ñ#EÔ#EÐ"FÐÐà#& 3 t t¨C¬J¸ÀÑ'KÔ'KÑ#LÔ#LÐ"MÐÐð 'Ø ð
Ðð
  #˜s 4 4¨¬
°G¸YÑ#GÔ#GÑHÔHÐIÐ Ð IÐ IÐ IÑ IðUð Uð Uð Uðp "˜c $ $ s¤z°5¸)Ñ"DÔ"DÑEÔEÐF€Ð FÐ FÐ FÑ FàÐÑÔð Ø	„w�$‚€Ð/€ð -¨Q¨Q¨QÔ/ÐÐà9˜\Ô9Ø˜u°ð
ñ 
ô 
ç
Š%�”
Ñ
Ô
ð 	Ðð „W�‚_€_ð ð 0Ø!˜c $ $Ð'7¸Ñ"CÔ"CÑDÔDÐEÐÐà,¨Q¨Q¨QÔ/ÐÐð 	!ØðÐðBð Bð Bð BðJð ð ð ð+ð +ð +ð +ð +ð\&ð &ð &ð &ð &ðR „<�7ÒÐØ'€N€Nà)€NðAð Að Að Að AðH)ð )ð )ð )ðXwFð wFð wFð wFðtð ð ð ð& "˜œ	Ð"AÀ7ÑKÔK×QÒQÑSÔSÐWdÐdÐ ð ð2ð 2ð 2ð 2ñ „ð2ðjð ð ð ð ð r   