
    IjA                       U d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ e
rdd	lmZ d
Zded<    G d de          Zd)dZd*dZd)dZddddddddddd d!Zd"ed#<   ed+d%            Zd)d&Zd+d'Z e            Zd)d(ZdgZdS ),zWindows.    )annotationsN)cache)Path)TYPE_CHECKINGFinal   )PlatformDirsABC)Callablei @  z
Final[int]_KF_FLAG_DONT_VERIFYc                     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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 dS )'Windowsa  `MSDN on where to store app data files <https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid>`_.

    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>`.

    returnstrc                    | j         rdnd}t          j                            t	          |                    }|                     |          S )zData 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      ^/workspace/show-city-briefing-agent/.venv/lib/python3.11/site-packages/platformdirs/windows.pyuser_data_dirzWindows.user_data_dir   sF     $(<J5Jwu 5 566!!$'''    Nopinion_valuer   r   
str | Nonec               z   g }| j         r| j        dur#| j        p| j         }|                    |           |                    | j                    || j        r|                    |           | j        r|                    | j                   t          j        j        |g|R  }|                     |           |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**74<f%%%MM$,'''(T\(m,,,| ,dl+++w|D*6***))$///r   c                    t           j                            t          d                    }|                     |          S )zLData 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_dir4   s6     w/E F FGG!!$'''r   c                    | j         S )z;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 )z:Config directory shared by users, same as `site_data_dir`.r/   r2   s    r   site_config_dirzWindows.site_config_dir?   r4   r   c                    t           j                            t          d                    }|                     |d          S )zCache 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_dirD   s;     w/D E EFF!!$g!>>>r   c                    t           j                            t          d                    }|                     |d          S )z\Cache directory shared by users, e.g. ``C:\ProgramData\$appauthor\$appname\Cache\$version``.r,   r9   r   r-   r.   s     r   site_cache_dirzWindows.site_cache_dirJ   s;     w/E F FGG!!$g!>>>r   c                    | j         S )z:State directory tied to the user, same as `user_data_dir`.r1   r2   s    r   user_state_dirzWindows.user_state_dirP   r4   r   c                    | j         S )z9State directory shared by users, same as `site_data_dir`.r6   r2   s    r   site_state_dirzWindows.site_state_dirU   r4   r   c                    | j         }| j        r5t          j                            |d          }|                     |           |S )z_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_dirZ   D     !< 	47<<f--D--d333r   c                    | j         }| j        r5t          j                            |d          }|                     |           |S )z^Log directory shared by users, same as `site_data_dir` if not opinionated else ``Logs`` in it.rB   )r/   r%   r   r   r'   r(   r.   s     r   site_log_dirzWindows.site_log_dirc   rD   r   c                Z    t           j                            t          d                    S )zFDocuments directory tied to the user e.g. ``%USERPROFILE%\Documents``.CSIDL_PERSONALr   r   r   r   r2   s    r   user_documents_dirzWindows.user_documents_dirl   #     w/? @ @AAAr   c                Z    t           j                            t          d                    S )zFDownloads directory tied to the user e.g. ``%USERPROFILE%\Downloads``.CSIDL_DOWNLOADSrI   r2   s    r   user_downloads_dirzWindows.user_downloads_dirq   s#     w/@ A ABBBr   c                Z    t           j                            t          d                    S )zDPictures directory tied to the user e.g. ``%USERPROFILE%\Pictures``.CSIDL_MYPICTURESrI   r2   s    r   user_pictures_dirzWindows.user_pictures_dirv   s#     w/A B BCCCr   c                Z    t           j                            t          d                    S )z@Videos directory tied to the user e.g. ``%USERPROFILE%\Videos``.CSIDL_MYVIDEOrI   r2   s    r   user_videos_dirzWindows.user_videos_dir{   "     w ? ?@@@r   c                Z    t           j                            t          d                    S )z>Music directory tied to the user e.g. ``%USERPROFILE%\Music``.CSIDL_MYMUSICrI   r2   s    r   user_music_dirzWindows.user_music_dir   rU   r   c                Z    t           j                            t          d                    S )zCDesktop directory tied to the user, e.g. ``%USERPROFILE%\Desktop``.CSIDL_DESKTOPDIRECTORYrI   r2   s    r   user_desktop_dirzWindows.user_desktop_dir   s#     w/G H HIIIr   c                z    t           j                            t           j                            d                    S )zEProjects directory tied to the user, e.g. ``%USERPROFILE%\Projects``.z
~/Projects)r   r   r   
expanduserr2   s    r   user_projects_dirzWindows.user_projects_dir   s*     w 2 2< @ @AAAr   c           
         t           j                            t           j                            dt          t          d                                          j        dz                                S )z0Public share directory e.g. ``C:\Users\Public``.PUBLIC~Public)	r   r   r   environgetr   r   r]   parentr2   s    r   user_publicshare_dirzWindows.user_publicshare_dir   sM     w
xT#YY=Q=Q=S=S=Z]e=e9f9f g ghhhr   c           	         t           j                            t          t	          t          d                    dz  dz  dz                      S )zTTemplates directory tied to the user e.g. ``%APPDATA%\Microsoft\Windows\Templates``.r   	Microsoftr   	Templatesr   r   r   r   r   r   r2   s    r   user_templates_dirzWindows.user_templates_dir   sC     wD)H)H$I$IK$WZc$cfq$q r rsssr   c           	         t           j                            t          t	          t          d                    dz  dz  dz                      S )zQFonts directory tied to the user e.g. ``%LOCALAPPDATA%\Microsoft\Windows\Fonts``.r   rh   r   Fontsrj   r2   s    r   user_fonts_dirzWindows.user_fonts_dir   sE     wD8M)N)N$O$OR]$]`i$ils$s t tuuur   c                    | j         S )zCPreference directory tied to the user, same as ``user_config_dir``.)r3   r2   s    r   user_preference_dirzWindows.user_preference_dir   s     ##r   c                    t           j                            t           j                            t	          d          d                    S )zABin directory tied to the user, e.g. ``%LOCALAPPDATA%\Programs``.r   Programsr   r   r   r'   r   r2   s    r   user_bin_dirzWindows.user_bin_dir   s4     w^<Q-R-RT^ _ _```r   c                    t           j                            t           j                            t	          d          d                    S )z;Bin directory shared by users, e.g. ``C:\ProgramData\bin``.r,   binrs   r2   s    r   site_bin_dirzWindows.site_bin_dir   s4     w^<R-S-SUZ [ [\\\r   c                Z    t           j                            t          d                    S )zFApplications directory tied to the user, e.g. ``Start Menu\Programs``.CSIDL_PROGRAMSrI   r2   s    r   user_applications_dirzWindows.user_applications_dir   rK   r   c                Z    t           j                            t          d                    S )zfApplications directory shared by users, e.g. ``C:\ProgramData\Microsoft\Windows\Start Menu\Programs``.CSIDL_COMMON_PROGRAMSrI   r2   s    r   site_applications_dirzWindows.site_applications_dir   s#     w/F G GHHHr   c                    t           j                            t           j                            t	          d          d                    }|                     |          S )zbRuntime 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   sG     w^<Q-R-RTZ [ [\\!!$'''r   c                    | j         S )z>Runtime directory shared by users, same as `user_runtime_dir`.)r   r2   s    r   site_runtime_dirzWindows.site_runtime_dir   s     $$r   )r   r   )r   r   r   r    r   r   )!__name__
__module____qualname____doc__propertyr   r   r/   r3   r7   r:   r<   r>   r@   rC   rF   rJ   rN   rQ   rT   rX   r[   r^   rf   rk   rn   rp   rt   rw   rz   r}   r   r    r   r   r   r      s         ( ( ( X( GK       ( ( ( X(
 " " " X" " " " X" ? ? ? X?
 ? ? ? X?
 " " " X" " " " X"    X    X B B B XB C C C XC D D D XD A A A XA A A A XA J J J XJ B B B XB i i i Xi t t t Xt v v v Xv $ $ $ X$ a a a Xa ] ] ] X] B B B XB I I I XI ( ( ( X(
 % % % X% % %r   r   
csidl_namer   r   c                    t          |           }||S dddd                    |           }|d|  }t          |          t          j                            |          }|d| }t          |          |S )z&Get folder from environment variables.NAPPDATAALLUSERSPROFILELOCALAPPDATA)r   r,   r   Unknown CSIDL name: zUnset environment variable: )(get_win_folder_if_csidl_name_not_env_varrd   
ValueErrorr   rc   )r   resultenv_var_namemsgs       r   get_win_folder_from_env_varsr      s    5jAAF # 1-  
c*oo	 
 1Z11ooZ^^L))F~;\;;ooMr   r    c                   | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d	          S | d
k    rMt           j                            t           j                            t           j        d                   d          S | dk    rMt           j                            t           j                            t           j        d                   d          S | dk    rPt           j                            t           j                            t           j        d                   dddd          S | dk    r|t           j                            t           j                            t           j                            dt           j                            dd                              dddd          S dS )zMGet a folder for a CSIDL name that does not exist as an environment variable.rH   USERPROFILE	DocumentsrM   	DownloadsrP   PicturesrS   VideosrW   MusicrZ   Desktopry   r   rh   r   z
Start Menurr   r|   PROGRAMDATAr   zC:\ProgramDataN)r   r   r'   r   rc   rd   r   s    r   r   r      s   %%%w||BG,,RZ-FGGUUU&&&w||BG,,RZ-FGGUUU'''w||BG,,RZ-FGGTTT_$$w||BG,,RZ-FGGRRR_$$w||BG,,RZ-FGGQQQ---w||BG,,RZ-FGGSSS%%%w||GRZ	233
 
 	
 ,,,w||GRZ^^M2:>>J[]n;o;oppqq
 
 	
 4r   c                ~   ddh}ddddddd	d
dddd                     |           }|d|  }t          |          t          j        dk    rt          ddl}| |v r|j        n|j        }|                    |d          5 }|	                    ||          \  }}ddd           n# 1 swxY w Y   t          |          S )zGet 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.

    r,   r|   AppDatazCommon AppDatazLocal AppDataPersonal&{374DE290-123F-4565-9164-39C4925E467B}zMy PictureszMy VideozMy Musicr   rr   zCommon Programs)r   r,   r   rH   rM   rP   rS   rW   rZ   ry   r|   Nr   win32r   z@Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)rd   r   sysplatformNotImplementedErrorwinregHKEY_LOCAL_MACHINEHKEY_CURRENT_USEROpenKeyQueryValueExr   )	r   machine_namesshell_folder_namer   r   hkeykey	directory_s	            r   get_win_folder_from_registryr      sG    	M
 # 0.$C)##"+$!2  
c*oo   1Z11oo
|w!!MMM )3m(C(C6$$IaD	a	b	b Cfi**30ABB	1C C C C C C C C C C C C C C Cy>>s   ?B%%B),B)z&{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}z&{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}z&{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}z&{FDD39AD0-238F-46AF-ADB4-6C85480369C7}z&{33E28130-4E1E-4676-835A-98395C3BC3BB}z&{18989B1D-99B5-455B-841C-AB7C74E4DDFC}z&{4BD8D571-6D19-48D3-BE97-422220080E43}r   z&{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}z&{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}z&{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8})r   r,   r   rH   rP   rS   rW   rM   rZ   ry   r|   zdict[str, str]_KNOWN_FOLDER_GUIDSCallable[[str], str]c                 D  	
 t           j        dk    rt          ddlm} m}m}m}mm	m
  G fdd|           |d          	| 	j        _        j         |          g	j        _        d	j        _        j        g	j        _         |d          
| 
j        _         |          j        j         |j                  g
j        _         |d	          j        j        _        j        j        j        gj        _        d	
fd}|S )zBuild the resolver once; a fresh ``_GUID`` per call leaks ctypes pointer types.

    See https://github.com/tox-dev/platformdirs/issues/501.

    r   r   )HRESULTPOINTER	StructureWinDLLbyrefcreate_unicode_bufferwintypesc                  Z    e Zd Zd j        fd j        fd j        fd j        dz  fgZdS )/_build_get_win_folder_via_ctypes.<locals>._GUIDData1Data2Data3Data4   N)r   r   r   DWORDWORDBYTE_fields_)r   s   r   _GUIDr   I  sC        hn%hm$hm$hma'(	
r   r   ole32Nshell32kernel32r   r   r   c                (   t                               |           }|d|  }t          |                       }                    | |                                                     }                     |          t          d  |                     |j        }                    |           |d|  }t          |          t          d |D                       r) 	d          }

                    ||d          r|j        }|S )Nr   z'SHGetKnownFolderPath returned NULL for c              3  <   K   | ]}t          |          d k    V  dS )   N)ord).0cs     r   	<genexpr>zD_build_get_win_folder_via_ctypes.<locals>.resolve.<locals>.<genexpr>q  s,      ,,s1vv|,,,,,,r   i   )r   rd   r   CLSIDFromStringLPWSTRSHGetKnownFolderPathr   valueCoTaskMemFreeanyGetShortPathNameW)r   folder_guidr   guidpath_ptrr   bufr   r   r   r   r   r   r   s          r   resolvez1_build_get_win_folder_via_ctypes.<locals>.resolve_  s'   )--j99555CS//!uwwk55;;777??$$$$UU4[[2FeeT\oo^^^H%%%>HJHHCS//!,,V,,,,, 	#''--C))&#t<< #r   r   r   r   r   )r   r   r   ctypesr   r   r   r   r   r   r   r   restype	LPCOLESTRargtypesr   LPVOIDr   r   HANDLEr   r   )r   r   r   r   r   r   r   r   r   r   r   r   s        @@@@@@@r    _build_get_win_folder_via_ctypesr   6  s    |w!!                 
 
 
 
 
 
 
	 
 
 
 F7OOE$+E!&.&8''%..%IE""&E$,O#4E fYG+2G (-4WU^^X^X_^e^efnfu^v^v,wG )vj!!H)1H&+3?HOX^*\H'           2 Nr   c                0     t                      |           S )zGet folder via :func:`SHGetKnownFolderPath`.

    See https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath.

    )r   r   s    r   get_win_folder_via_ctypesr   {  s     .+--j999r   c                     	 ddl } t          S # t          $ r Y nw xY w	 ddl}t          S # t          $ r
 t
          cY S w xY w)zjSelect the best method to resolve Windows folder paths: ctypes, then registry, then environment variables.r   N)r   r   ImportErrorr   r   r   )r   r   s     r   _pick_get_win_folderr     sy    ) )(    , ,+  , , ,++++,s    
) ==c                    d|                      d           }t          j                            |d                                          x}r|S t          |           S )zGet a Windows folder path, checking for ``WIN_PD_OVERRIDE_*`` environment variable overrides first.

    For example, ``CSIDL_LOCAL_APPDATA`` can be overridden by setting ``WIN_PD_OVERRIDE_LOCAL_APPDATA``.

    WIN_PD_OVERRIDE_CSIDL_ )removeprefixr   rc   rd   strip_resolve_win_folder)r   env_varoverrides      r   r   r     s\     E!8!8!B!BDDG:>>'2..44666x z***r   r   )r   r   r   r    )r   r   )r   
__future__r   r   r   	functoolsr   pathlibr   typingr   r   apir	   collections.abcr
   r   __annotations__r   r   r   r   r   r   r   r   r   r   __all__r   r   r   <module>r      s    " " " " " " 				 



             ' ' ' ' ' ' ' '             )(((((( $.  - - - -l% l% l% l% l%o l% l% l%^   *% % % %P$ $ $ $P >DC>@==?F>E' '      A A A AH: : : :, , , ,  +*,, 	+ 	+ 	+ 	+ r   