Mini Shell

Direktori : /proc/self/root/lib/python3.6/site-packages/xdg/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/xdg/__pycache__/BaseDirectory.cpython-36.opt-1.pyc

3

�Y�]~�@sdZddlZddlZejjd�Zejjd�p:ejjedd�Z	e	gejjd�pNdj
d	�Zejjd
�ppejjed�Zegejjd�p�d
j
d	�Z
ejjd�p�ejjed�Zdd�eD�Zdd�e
D�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd"d d!�ZdS)#a
This module is based on a rox module (LGPL):

http://cvs.sourceforge.net/viewcvs.py/rox/ROX-Lib2/python/rox/basedir.py?rev=1.9&view=log

The freedesktop.org Base Directory specification provides a way for
applications to locate shared data and configuration:

    http://standards.freedesktop.org/basedir-spec/

(based on version 0.6)

This module can be used to load and save from and to these directories.

Typical usage:

    from rox import basedir
    
    for dir in basedir.load_config_paths('mydomain.org', 'MyProg', 'Options'):
        print "Load settings from", dir

    dir = basedir.save_config_path('mydomain.org', 'MyProg')
    print >>file(os.path.join(dir, 'Options'), 'w'), "foo=2"

Note: see the rox.Options module for a higher-level API for managing options.
�N�~Z
XDG_DATA_HOMEz.localZshareZ
XDG_DATA_DIRSz/usr/local/share:/usr/share�:ZXDG_CONFIG_HOMEz.configZXDG_CONFIG_DIRSz/etc/xdgZXDG_CACHE_HOMEz.cachecCsg|]}|r|�qS�r)�.0�xrr�#/usr/lib/python3.6/BaseDirectory.py�
<listcomp>.srcCsg|]}|r|�qSrr)rrrrrr/scGs6tjj|�}tjjt|�}tjj|�s2tj|d�|S)z�Ensure ``$XDG_CONFIG_HOME/<resource>/`` exists, and return its path.
    'resource' should normally be the name of your application. Use this
    when saving configuration settings.
    i�)�os�path�join�xdg_config_home�isdir�makedirs)�resourcer
rrr�save_config_path1s
rcGs4tjj|�}tjjt|�}tjj|�s0tj|�|S)z�Ensure ``$XDG_DATA_HOME/<resource>/`` exists, and return its path.
    'resource' should normally be the name of your application or a shared
    resource. Use this when saving or updating application data.
    )r	r
r�
xdg_data_homer
r)rr
rrr�save_data_path=s

rcGs4tjj|�}tjjt|�}tjj|�s0tj|�|S)z�Ensure ``$XDG_CACHE_HOME/<resource>/`` exists, and return its path.
    'resource' should normally be the name of your application or a shared
    resource.)r	r
r�xdg_cache_homer
r)rr
rrr�save_cache_pathIs

rcgs>tjj|�}x,tD]$}tjj||�}tjj|�r|VqWdS)z�Returns an iterator which gives each directory named 'resource' in the
    configuration search path. Information provided by earlier directories should
    take precedence over later ones, and the user-specific config dir comes
    first.N)r	r
r�xdg_config_dirs�exists)rZ
config_dirr
rrr�load_config_pathsTs

rcGsxt|�D]}|SWdS)zYReturns the first result from load_config_paths, or None if there is nothing
    to load.N)r)rrrrr�load_first_config^srcgs>tjj|�}x,tD]$}tjj||�}tjj|�r|VqWdS)z�Returns an iterator which gives each directory named 'resource' in the
    application data search path. Information provided by earlier directories
    should take precedence over later ones.N)r	r
r�
xdg_data_dirsr)rZdata_dirr
rrr�load_data_pathses

rTcCs�y
tjdStk
r�|r �ddl}d|j�}d}ytj|�}Wn>tk
r�}z"ddl}|j|jkrrd}n�WYdd}~XnLXt	j
|j�s�tj|�d}n.|j
tj�ks�|jt	jt	jB@r�tj|�d}|r�tj|d�|SXdS)aReturns the value of $XDG_RUNTIME_DIR, a directory path.
    
    This directory is intended for 'user-specific non-essential runtime files
    and other file objects (such as sockets, named pipes, ...)', and
    'communication and synchronization purposes'.
    
    As of late 2012, only quite new systems set $XDG_RUNTIME_DIR. If it is not
    set, with ``strict=True`` (the default), a KeyError is raised. With 
    ``strict=False``, PyXDG will create a fallback under /tmp for the current
    user. This fallback does *not* provide the same guarantees as the
    specification requires for the runtime directory.
    
    The strict default is deliberately conservative, so that application
    developers can make a conscious decision to allow the fallback.
    ZXDG_RUNTIME_DIRrNz /tmp/pyxdg-runtime-dir-fallback-FTi�)r	�environ�KeyError�getpassZgetuser�lstat�OSError�errno�ENOENT�stat�S_ISDIR�st_mode�unlink�st_uid�getuid�S_IRWXG�S_IRWXO�rmdir�mkdir)�strictrZfallbackZcreate�st�er rrr�get_runtime_dirns2


r/)T)�__doc__r	r"r
�
expanduser�_homer�getrr�splitrrrrrrrrrrr/rrrr�<module>s*