Ë
    äØjje%  ã                  óÌ   — d Z ddlm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 e	rddlmZ  G d	„ d
e«      Zdd„Zdd„Zdd„Zdd„Zdd„Z  ed¬«       e«       «      Zd
gZy)zWindows.é    )ÚannotationsN)Ú	lru_cache)ÚTYPE_CHECKINGé   )ÚPlatformDirsABC)ÚCallablec                  ó  — e Zd ZdZedd„«       Zddœdd„Zedd„«       Zedd„«       Zedd„«       Z	edd	„«       Z
edd
„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Zy)ÚWindowsa  
    `MSDN on where to store app data files
    <http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120>`_.
    Makes use of the
    `appname <platformdirs.api.PlatformDirsABC.appname>`,
    `appauthor <platformdirs.api.PlatformDirsABC.appauthor>`,
    `version <platformdirs.api.PlatformDirsABC.version>`,
    `roaming <platformdirs.api.PlatformDirsABC.roaming>`,
    `opinion <platformdirs.api.PlatformDirsABC.opinion>`,
    `ensure_exists <platformdirs.api.PlatformDirsABC.ensure_exists>`.
    c                ó”   — | j                   rdnd}t        j                  j                  t	        |«      «      }| j                  |«      S )z×
        :return: data directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\$appauthor\$appname`` (not roaming) or
         ``%USERPROFILE%\AppData\Roaming\$appauthor\$appname`` (roaming)
        ÚCSIDL_APPDATAÚCSIDL_LOCAL_APPDATA)ÚroamingÚosÚpathÚnormpathÚget_win_folderÚ_append_parts)ÚselfÚconstr   s      úb/opt/eval-harness/bench_task/venv/lib/python3.12/site-packages/pip/_vendor/platformdirs/windows.pyÚuser_data_dirzWindows.user_data_dir   s<   € ð $(§<¢<‘Ð5JˆÜ�w‰w×Ñ¤¨uÓ 5Ó6ˆØ×!Ñ! $Ó'Ð'ó    N©Úopinion_valuec               ó¸  — g }| j                   rš| j                  dur+| j                  xs | j                   }|j                  |«       |j                  | j                   «       |�| j                  r|j                  |«       | j                  r|j                  | j                  «       t        j                  j                  |g|¢­Ž }| j                  |«       |S )NF)	ÚappnameÚ	appauthorÚappendÚopinionÚversionr   r   ÚjoinÚ_optionally_create_directory)r   r   r   ÚparamsÚauthors        r   r   zWindows._append_parts(   s¡   € ØˆØ�<Š<Ø�~‰~ UÑ*ØŸ™Ò7¨4¯<©<�Ø—‘˜fÔ%Ø�M‰M˜$Ÿ,™,Ô'ØÐ(¨T¯\ª\Ø—‘˜mÔ,Ø�|Š|Ø—‘˜dŸl™lÔ+Ü�w‰w�|‰|˜DÐ* 6Ò*ˆØ×)Ñ)¨$Ô/Øˆr   c                ót   — t         j                  j                  t        d«      «      }| j	                  |«      S )zT:return: data directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname``ÚCSIDL_COMMON_APPDATA©r   r   r   r   r   ©r   r   s     r   Úsite_data_dirzWindows.site_data_dir7   s/   € ô �w‰w×Ñ¤Ð/EÓ FÓGˆØ×!Ñ! $Ó'Ð'r   c                ó   — | j                   S )zC:return: config directory tied to the user, same as `user_data_dir`©r   ©r   s    r   Úuser_config_dirzWindows.user_config_dir=   ó   € ð ×!Ñ!Ð!r   c                ó   — | j                   S )zF:return: config directory shared by the users, same as `site_data_dir`)r)   r,   s    r   Úsite_config_dirzWindows.site_config_dirB   r.   r   c                óx   — t         j                  j                  t        d«      «      }| j	                  |d¬«      S )zÇ
        :return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g.
         ``%USERPROFILE%\AppData\Local\$appauthor\$appname\Cache\$version``
        r   ÚCacher   r'   r(   s     r   Úuser_cache_dirzWindows.user_cache_dirG   s4   € ô �w‰w×Ñ¤Ð/DÓ EÓFˆØ×!Ñ! $°gÐ!Ó>Ð>r   c                óx   — t         j                  j                  t        d«      «      }| j	                  |d¬«      S )zd:return: cache directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname\Cache\$version``r&   r2   r   r'   r(   s     r   Úsite_cache_dirzWindows.site_cache_dirP   s4   € ô �w‰w×Ñ¤Ð/EÓ FÓGˆØ×!Ñ! $°gÐ!Ó>Ð>r   c                ó   — | j                   S )zB:return: state directory tied to the user, same as `user_data_dir`r+   r,   s    r   Úuser_state_dirzWindows.user_state_dirV   r.   r   c                ó˜   — | j                   }| j                  r1t        j                  j	                  |d«      }| j                  |«       |S )zg:return: log directory tied to the user, same as `user_data_dir` if not opinionated else ``Logs`` in itÚLogs)r   r   r   r   r!   r"   r(   s     r   Úuser_log_dirzWindows.user_log_dir[   s=   € ð ×!Ñ!ˆØ�<Š<Ü—7‘7—<‘<  fÓ-ˆDØ×-Ñ-¨dÔ3Øˆr   c                óR   — t         j                  j                  t        d«      «      S )zN:return: documents directory tied to the user e.g. ``%USERPROFILE%\Documents``ÚCSIDL_PERSONAL©r   r   r   r   r,   s    r   Úuser_documents_dirzWindows.user_documents_dird   s   € ô �w‰w×Ñ¤Ð/?Ó @ÓAÐAr   c                óR   — t         j                  j                  t        d«      «      S )zN:return: downloads directory tied to the user e.g. ``%USERPROFILE%\Downloads``ÚCSIDL_DOWNLOADSr=   r,   s    r   Úuser_downloads_dirzWindows.user_downloads_diri   s   € ô �w‰w×Ñ¤Ð/@Ó AÓBÐBr   c                óR   — t         j                  j                  t        d«      «      S )zL:return: pictures directory tied to the user e.g. ``%USERPROFILE%\Pictures``ÚCSIDL_MYPICTURESr=   r,   s    r   Úuser_pictures_dirzWindows.user_pictures_dirn   s   € ô �w‰w×Ñ¤Ð/AÓ BÓCÐCr   c                óR   — t         j                  j                  t        d«      «      S )zH:return: videos directory tied to the user e.g. ``%USERPROFILE%\Videos``ÚCSIDL_MYVIDEOr=   r,   s    r   Úuser_videos_dirzWindows.user_videos_dirs   ó   € ô �w‰w×Ñ¤¨Ó ?Ó@Ð@r   c                óR   — t         j                  j                  t        d«      «      S )zF:return: music directory tied to the user e.g. ``%USERPROFILE%\Music``ÚCSIDL_MYMUSICr=   r,   s    r   Úuser_music_dirzWindows.user_music_dirx   rH   r   c                ó°   — t         j                  j                  t         j                  j                  t	        d«      d«      «      }| j                  |«      S )z…
        :return: runtime directory tied to the user, e.g.
         ``%USERPROFILE%\AppData\Local\Temp\$appauthor\$appname``
        r   ÚTemp)r   r   r   r!   r   r   r(   s     r   Úuser_runtime_dirzWindows.user_runtime_dir}   s?   € ô �w‰w×Ñ¤§¡§¡¬^Ð<QÓ-RÐTZÓ [Ó\ˆØ×!Ñ! $Ó'Ð'r   )ÚreturnÚstr)r   rP   r   ú
str | NonerO   rP   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   r)   r-   r0   r3   r5   r7   r:   r>   rA   rD   rG   rK   rN   © r   r   r
   r
      s5  „ ñ
ð ò(ó ð(ð GKõ ð ò(ó ð(ð
 ò"ó ð"ð ò"ó ð"ð ò?ó ð?ð ò?ó ð?ð
 ò"ó ð"ð òó ðð òBó ðBð òCó ðCð òDó ðDð òAó ðAð òAó ðAð ò(ó ñ(r   r
   c                óÔ   — t        | «      }|�|S ddddœj                  | «      }|€d| › �}t        |«      ‚t        j                  j                  |«      }|€d|› �}t        |«      ‚|S )z&Get folder from environment variables.ÚAPPDATAÚALLUSERSPROFILEÚLOCALAPPDATA)r   r&   r   úUnknown CSIDL name: zUnset environment variable: )Ú(get_win_folder_if_csidl_name_not_env_varÚgetÚ
ValueErrorr   Úenviron)Ú
csidl_nameÚresultÚenv_var_nameÚmsgs       r   Úget_win_folder_from_env_varsre   ‡   s‡   € ä5°jÓA€FØÐØˆð #Ø 1Ø-ñ÷ 
�cˆ*ƒoð	 ð
 ÐØ$ Z LÐ1ˆÜ˜‹oÐÜ�Z‰Z�^‰^˜LÓ)€FØ€~Ø,¨\¨NÐ;ˆÜ˜‹oÐØ€Mr   c                óB  — | dk(  rNt         j                  j                  t         j                  j                  t         j                  d   «      d«      S | dk(  rNt         j                  j                  t         j                  j                  t         j                  d   «      d«      S | dk(  rNt         j                  j                  t         j                  j                  t         j                  d   «      d«      S | dk(  rNt         j                  j                  t         j                  j                  t         j                  d   «      d	«      S | d
k(  rNt         j                  j                  t         j                  j                  t         j                  d   «      d«      S y)zKGet folder for a CSIDL name that does not exist as an environment variable.r<   ÚUSERPROFILEÚ	Documentsr@   Ú	DownloadsrC   ÚPicturesrF   ÚVideosrJ   ÚMusicN)r   r   r!   r   r`   )ra   s    r   r]   r]   œ   s  € àÐ%Ò%Ü�w‰w�|‰|œBŸG™G×,Ñ,¬R¯Z©Z¸Ñ-FÓGÈÓUÐUàÐ&Ò&Ü�w‰w�|‰|œBŸG™G×,Ñ,¬R¯Z©Z¸Ñ-FÓGÈÓUÐUàÐ'Ò'Ü�w‰w�|‰|œBŸG™G×,Ñ,¬R¯Z©Z¸Ñ-FÓGÈÓTÐTà�_Ò$Ü�w‰w�|‰|œBŸG™G×,Ñ,¬R¯Z©Z¸Ñ-FÓGÈÓRÐRà�_Ò$Ü�w‰w�|‰|œBŸG™G×,Ñ,¬R¯Z©Z¸Ñ-FÓGÈÓQÐQØr   c           	     ó  — ddddddddd	œj                  | «      }|€d| › �}t        |«      ‚t        j                  dk7  rt        ‚dd
l}|j                  |j                  d«      }|j                  ||«      \  }}t        |«      S )z»
    Get folder from the registry.

    This is a fallback technique at best. I'm not sure if using the registry for these guarantees us the correct answer
    for all CSIDL_* names.
    ÚAppDatazCommon AppDatazLocal AppDataÚPersonalz&{374DE290-123F-4565-9164-39C4925E467B}zMy PictureszMy VideozMy Music)r   r&   r   r<   r@   rC   rF   rJ   Nr\   Úwin32r   z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)
r^   r_   ÚsysÚplatformÚNotImplementedErrorÚwinregÚOpenKeyÚHKEY_CURRENT_USERÚQueryValueExrP   )ra   Úshell_folder_namerd   rt   ÚkeyÚ	directoryÚ_s          r   Úget_win_folder_from_registryr|   ¯   sœ   € ð #Ø 0Ø.Ø$ØCØ)Ø#Ø#ñ	÷ 
�cˆ*ƒoð ð Ð Ø$ Z LÐ1ˆÜ˜‹oÐÜ
‡|�|�wÒÜ!Ð!Ûà
�.‰.˜×1Ñ1Ð3vÓ
w€CØ×&Ñ& sÐ,=Ó>�L€IˆqÜˆy‹>Ðr   c           	     óø  — ddddddddd	œj                  | «      }|€d| › �}t        |«      ‚t        j                  d«      }t	        t        d«      }|j
                  j                  d
|d
d|«       t        d„ |D «       «      r>t        j                  d«      }|j                  j                  |j                  |d«      r|}| dk(  r*t        j                  j                  |j                  d«      S |j                  S )zGet folder with ctypes.é   é#   é   é   é'   é   é   é(   )r   r&   r   r<   rC   rF   rJ   r@   Nr\   i   Úwindllr   c              3  ó8   K  — | ]  }t        |«      d kD  –— Œ y­w)éÿ   N)Úord)Ú.0Úcs     r   ú	<genexpr>z,get_win_folder_via_ctypes.<locals>.<genexpr>å   s   è ø€ Ò
%˜AŒ3ˆq‹6�C�<Ñ
%ùs   ‚r@   ri   )r^   r_   ÚctypesÚcreate_unicode_bufferÚgetattrÚshell32ÚSHGetFolderPathWÚanyÚkernel32ÚGetShortPathNameWÚvaluer   r   r!   )ra   Úcsidl_constrd   Úbufr†   Úbuf2s         r   Úget_win_folder_via_ctypesr™   Ì   sð   € ð Ø "Ø!ØØØØØñ	÷ 
�cˆ*ƒoð ð ÐØ$ Z LÐ1ˆÜ˜‹oÐä
×
&Ñ
& tÓ
,€CÜ”V˜XÓ&€FØ
‡N�N×#Ñ# D¨+°t¸QÀÔDô Ñ
% Ô
%Ô%Ü×+Ñ+¨DÓ1ˆØ�?‰?×,Ñ,¨S¯Y©Y¸¸dÔCØˆCàÐ&Ò&Ü�w‰w�|‰|˜CŸI™I {Ó3Ð3à�9‰9Ðr   c                 ón   — t        t        d«      rt        S 	 dd l} t        S # t
        $ r	 t        cY S w xY w)Nr†   r   )Úhasattrr�   r™   rt   r|   ÚImportErrorre   )rt   s    r   Ú_pick_get_win_folderr�   ð   s9   € ÜŒv�xÔ Ü(Ð(ð,Ûô ,Ð+øô ò ,Ü+Ò+ð,ús   ˜" ¢4³4)Úmaxsize)ra   rP   rO   rP   )ra   rP   rO   rQ   )rO   zCallable[[str], str])rU   Ú
__future__r   r�   r   rq   Ú	functoolsr   Útypingr   Úapir   Úcollections.abcr   r
   re   r]   r|   r™   r�   r   Ú__all__rW   r   r   ú<module>r¥      so   ðÙ Ý "ã Û 	Û 
Ý Ý  å  áÝ(ôt(ˆoô t(ónó*ó&ó:!óH,ð )‘ 4Ô(Ñ)=Ó)?Ó@€ð ð�r   