U
    ܦ\                     @   s   d dl mZ d dlZd dlZdd Zdd Zdd Zd	d
 ZeZdd Z	dd Z
e de  eZe de  e
ZdS )    )absolute_importNc                   C   s   t jt jd dS )NZUSERPROFILEzLocal Settings)ospathjoinenviron r   r   8/usr/lib/python3/dist-packages/keyring/util/platform_.py_settings_root_XP   s    r	   c                   C   s   t jdt jddS )NZLOCALAPPDATAZProgramData.)r   r   getr   r   r   r   _settings_root_Vista   s    r   c                  C   s2   t  \} }}}| dkrt nt }tj|dS )NZXPzPython Keyring)platformZ	win32_verr	   r   r   r   r   )releaseversionZcsdZptyperootr   r   r   _data_root_Windows   s    r   c                  C   s,   t jd} t jddp| }t j|dS )zV
    Use freedesktop.org Base Dir Specfication to determine storage
    location.
    ~/.local/shareZXDG_DATA_HOMENpython_keyring)r   r   
expanduserr   r   r   )fallbackr   r   r   r   _data_root_Linux   s    r   c                  C   s`   dd t  d< tjt d} tjt d}tj|r\tj| s\d}t|jf t	 dS )a  
    Prior versions of keyring would search for the config
    in XDG_DATA_HOME, but should probably have been
    searching for config in XDG_CONFIG_HOME. If the
    config exists in the former but not in the latter,
    raise a RuntimeError to force the change.
    c                   S   s   d S )Nr   r   r   r   r   <lambda>+       z(_check_old_config_root.<locals>.<lambda>_check_old_config_rootzkeyringrc.cfgzKeyring config exists only in the old location {config_file_old} and should be moved to {config_file_new} to work with this version of keyring.N)
globalsr   r   r   _config_root_Linuxr   isfileRuntimeErrorformatlocals)Zconfig_file_newZconfig_file_oldmsgr   r   r   r   "   s    	r   c                  C   s6   t   tjd} d}tj|dp&| }tj|dS )zU
    Use freedesktop.org Base Dir Specfication to determine config
    location.
    r   ZXDG_CONFIG_HOMENr   )r   r   r   r   r   r   r   )r   keyr   r   r   r   r   5   s
    r   Z_data_root_Z_config_root)Z
__future__r   r   r   r	   r   r   r   Z_config_root_Windowsr   r   r   r   systemZ	data_rootZconfig_rootr   r   r   r   <module>   s   

