§
    Öu•cu  ã                   ó(  — d Z ddlZddlZej                             d¦  «        Zej                             d¦  «        pej                             edd¦  «        Z	e	gej                             d¦  «        pd 
                    d	¦  «        z   Zej                             d
¦  «        pej                             ed¦  «        Zegej                             d¦  «        pd 
                    d	¦  «        z   Zej                             d¦  «        pej                             ed¦  «        Zej                             d¦  «        pej                             edd¦  «        Zd„ eD ¦   «         Zd„ eD ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„ZdS )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ú~ÚXDG_DATA_HOMEz.localÚshareÚXDG_DATA_DIRSz/usr/local/share:/usr/shareú:ÚXDG_CONFIG_HOMEz.configÚXDG_CONFIG_DIRSz/etc/xdgÚXDG_CACHE_HOMEz.cacheÚXDG_STATE_HOMEÚstatec                 ó   — g | ]}|¯|‘ŒS © r   ©Ú.0Úxs     ú3/usr/lib/python3/dist-packages/xdg/BaseDirectory.pyú
<listcomp>r   1   s   € Ð/Ð/Ð/�q¨QÐ/�Ð/Ð/Ð/ó    c                 ó   — g | ]}|¯|‘ŒS r   r   r   s     r   r   r   2   s   € Ð3Ð3Ð3˜°Ð3�1Ð3Ð3Ð3r   c                  ó  — t          j        j        | Ž } |                      d¦  «        rJ ‚t           j                             t          | ¦  «        }t           j                             |¦  «        st          j        |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.
    ú/éÀ  )ÚosÚpathÚjoinÚ
startswithÚxdg_config_homeÚisdirÚmakedirs©Úresourcer   s     r   Úsave_config_pathr"   4   sn   € õ
 ŒwŒ|˜XÐ&€HØ×"Ò" 3Ñ'Ô'Ð'Ð'Ð'ÝŒ7�<Š<�¨Ñ2Ô2€DÝŒ7�=Š=˜ÑÔð !Ý
Œ�D˜%Ñ Ô Ð Ø€Kr   c                  ó
  — t          j        j        | Ž } |                      d¦  «        rJ ‚t           j                             t          | ¦  «        }t           j                             |¦  «        st          j        |¦  «         |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   r   r   Úxdg_data_homer   r   r    s     r   Úsave_data_pathr%   @   sl   € õ
 ŒwŒ|˜XÐ&€HØ×"Ò" 3Ñ'Ô'Ð'Ð'Ð'ÝŒ7�<Š<� xÑ0Ô0€DÝŒ7�=Š=˜ÑÔð Ý
Œ�DÑÔÐØ€Kr   c                  ó
  — t          j        j        | Ž } |                      d¦  «        rJ ‚t           j                             t          | ¦  «        }t           j                             |¦  «        st          j        |¦  «         |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   r   r   Úxdg_cache_homer   r   r    s     r   Úsave_cache_pathr(   L   ól   € õ ŒwŒ|˜XÐ&€HØ×"Ò" 3Ñ'Ô'Ð'Ð'Ð'ÝŒ7�<Š<�¨Ñ1Ô1€DÝŒ7�=Š=˜ÑÔð Ý
Œ�DÑÔÐØ€Kr   c                  ó
  — t          j        j        | Ž } |                      d¦  «        rJ ‚t           j                             t          | ¦  «        }t           j                             |¦  «        st          j        |¦  «         |S )zœEnsure ``$XDG_STATE_HOME/<resource>/`` exists, and return its path.
    'resource' should normally be the name of your application or a shared
    resource.r   )r   r   r   r   Úxdg_state_homer   r   r    s     r   Úsave_state_pathr,   W   r)   r   c               '   óÊ   K  — t          j        j        | Ž } t          D ]E}t           j                             || ¦  «        }t           j                             |¦  «        r|V — ŒFdS )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)r!   Ú
config_dirr   s      r   Úload_config_pathsr1   b   sa   è è € õ
 ŒwŒ|˜XÐ&€HÝ%ð ,ð ,ˆ
ÝŒw�|Š|˜J¨Ñ1Ô1ˆÝŒ7�>Š>˜$ÑÔÐ+ t   øð,ð ,r   c                  ó$   — t          | Ž D ]}|c S dS )zYReturns the first result from load_config_paths, or None if there is nothing
    to load.N)r1   )r!   r   s     r   Úload_first_configr3   l   s&   € õ  Ð)ð ð ˆØˆˆˆØˆ4r   c               '   óÊ   K  — t          j        j        | Ž } t          D ]E}t           j                             || ¦  «        }t           j                             |¦  «        r|V — ŒFdS )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/   )r!   Údata_dirr   s      r   Úload_data_pathsr7   s   sa   è è € õ ŒwŒ|˜XÐ&€HÝ!ð ,ð ,ˆÝŒw�|Š|˜H hÑ/Ô/ˆÝŒ7�>Š>˜$ÑÔÐ+ t   øð,ð ,r   Tc                 óL  — 	 t           j        d         S # t          $ �r | r‚ ddl}d|                     ¦   «         z   }d}	 t          j        |¦  «        }t          j        |j        ¦  «        st          j	        |¦  «         d}nƒ|j
        t          j        ¦   «         k    s!|j        t          j        t          j        z  z  rt          j        |¦  «         d}n/# t          $ r"}ddl}|j        |j        k    rd}n‚ Y d}~nd}~ww xY w|rt          j        |d¦  «         |cY S w xY w)a   Returns 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.
    ÚXDG_RUNTIME_DIRr   Nz /tmp/pyxdg-runtime-dir-fallback-FTr   )r   ÚenvironÚKeyErrorÚgetpassÚgetuserÚlstatÚstatÚS_ISDIRÚst_modeÚunlinkÚst_uidÚgetuidÚS_IRWXGÚS_IRWXOÚrmdirÚOSErrorÚerrnoÚENOENTÚmkdir)Ústrictr<   ÚfallbackÚcreateÚstÚerI   s          r   Úget_runtime_dirrQ   |   sW  € ð "ÝŒzÐ+Ô,Ð,øÝð  ñ  ð  Øð 	ØàˆˆˆØ5¸¿ºÑ8IÔ8IÑIˆØˆð	õ ”˜(Ñ#Ô#ˆBõ ”< ¤
Ñ+Ô+ð Ý”	˜(Ñ#Ô#Ð#Ø��à”)�rœy™{œ{Ò*Ð*Ø”*¥¤­t¬|Ñ ;Ñ<ð +å”˜Ñ"Ô"Ð"Ø�øøõ ð 	ð 	ð 	ØˆLˆLˆLØŒw˜%œ,Ò&Ð&Ø��àð ����øøøøð	øøøð" ð 	&ÝŒH�X˜uÑ%Ô%Ð%àˆˆˆðA øøøs:   ‚ ”+D#Á CÁBD#Ã
DÃ"C?Ã:D#Ã?DÄD#Ä"D#)T)Ú__doc__r   r?   r   Ú
expanduserÚ_homer:   Úgetr   r$   Úsplitr5   r   r.   r'   r+   r"   r%   r(   r,   r1   r3   r7   rQ   r   r   r   ú<module>rW      s  ððð ð6 €€€€€€€à
Œ×Ò˜3ÑÔ€Ø”
—’˜Ñ/Ô/ð 3ØŒG�LŠL˜ ¨'Ñ2Ô2ð ð �Ø„Z‡^‚^�OÑ$Ô$ÐEÐ(E×LÒLÈSÑQÔQñR€ð ”*—.’.Ð!2Ñ3Ô3ð +ØŒG�LŠL˜ 	Ñ*Ô*ð ð #Ð#Ø„Z‡^‚^Ð%Ñ&Ô&Ð4¨*×;Ò;¸CÑ@Ô@ñA€ð ”—’Ð 0Ñ1Ô1ð *ØŒG�LŠL˜ Ñ)Ô)ð ð ”—’Ð 0Ñ1Ô1ð 3ØŒG�LŠL˜ ¨'Ñ2Ô2ð ð 0Ð/˜MÐ/Ñ/Ô/€Ø3Ð3˜oÐ3Ñ3Ô3€ð
ð 
ð 
ð
ð 
ð 
ð	ð 	ð 	ð	ð 	ð 	ð,ð ,ð ,ðð ð ð,ð ,ð ,ð2ð 2ð 2ð 2ð 2ð 2r   