Ë
    Öu•cu  ã                   ót  — d Z ddlZddlZej                  j	                  d«      Zej                  j                  d«      xs ej                  j                  edd«      Z	e	gej                  j                  d«      xs dj                  d	«      z   Zej                  j                  d
«      xs ej                  j                  ed«      Zegej                  j                  d«      xs dj                  d	«      z   Zej                  j                  d«      xs ej                  j                  ed«      Zej                  j                  d«      xs ej                  j                  edd«      ZeD � cg c]  } | sŒ| ‘Œ	 c} ZeD � cg c]  } | sŒ| ‘Œ	 c} Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zyc c} w c c} w )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                  ó  — t        j                  j                  | Ž } | j                  d«      rJ ‚t         j                  j                  t        | «      }t         j                  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     ú3/usr/lib/python3/dist-packages/xdg/BaseDirectory.pyÚsave_config_pathr   4   sa   € ô
 �w‰w�|‰|˜XÐ&€HØ×"Ñ" 3Ô'Ð'Ð'Ü�7‰7�<‰<œ¨Ó2€DÜ�7‰7�=‰=˜ÔÜ
�‰�D˜%Ô Ø€Kó    c                  ó  — t        j                  j                  | Ž } | j                  d«      rJ ‚t         j                  j                  t        | «      }t         j                  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   @   s_   € ô
 �w‰w�|‰|˜XÐ&€HØ×"Ñ" 3Ô'Ð'Ð'Ü�7‰7�<‰<œ xÓ0€DÜ�7‰7�=‰=˜ÔÜ
�‰�DÔØ€Kr   c                  ó  — t        j                  j                  | Ž } | j                  d«      rJ ‚t         j                  j                  t        | «      }t         j                  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   ó_   € ô �w‰w�|‰|˜XÐ&€HØ×"Ñ" 3Ô'Ð'Ð'Ü�7‰7�<‰<œ¨Ó1€DÜ�7‰7�=‰=˜ÔÜ
�‰�DÔØ€Kr   c                  ó  — t        j                  j                  | Ž } | j                  d«      rJ ‚t         j                  j                  t        | «      }t         j                  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 ]F  }t         j                  j                  || «      }t         j                  j	                  |«      sŒC|–— ŒH y­w)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_pathsr*   b   sQ   è ø€ ô
 �w‰w�|‰|˜XÐ&€HÜ%ò ,ˆ
Ü�w‰w�|‰|˜J¨Ó1ˆÜ�7‰7�>‰>˜$Õ t£ñ,ùó   ‚A%A/Á(A/c                  ó$   — t        | Ž D ]  }|c S  y)zYReturns the first result from load_config_paths, or None if there is nothing
    to load.N)r*   )r   Úxs     r   Úload_first_configr.   l   s    € ô  Ð)ò ˆØŠðàr   c               '   óâ   K  — t        j                  j                  | Ž } t        D ]F  }t         j                  j                  || «      }t         j                  j	                  |«      sŒC|–— ŒH y­w)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_pathsr2   s   sQ   è ø€ ô �w‰w�|‰|˜XÐ&€HÜ!ò ,ˆÜ�w‰w�|‰|˜H hÓ/ˆÜ�7‰7�>‰>˜$Õ t£ñ,ùr+   c                 óŒ  — 	 t         j                  d   S # t        $ �r$ | r‚ ddl}d|j	                  «       z   }d}	 t        j
                  |«      }t        j                  |j                  «      st        j                  |«       d}nž|j                  t        j                  «       k7  s.|j                  t        j                  t        j                  z  z  rOt        j                  |«       d}n7# 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)Ústrictr7   ÚfallbackÚcreateÚstÚerD   s          r   Úget_runtime_dirrL   |   s  € ð "Ü�z‰zÐ+Ñ,Ð,øÜó  ÙØãØ5¸¿¹Ó8IÑIˆØˆð	ô —‘˜(Ó#ˆBô —<‘< §
¡
Ô+Ü—	‘	˜(Ô#Ø‘à—)‘)œrŸy™y›{Ò*Ø—*‘*¤§¡¬t¯|©|Ñ ;Ò<Ü—‘˜Ô"Ø‘øô ò 	ÛØ�w‰w˜%Ÿ,™,Ò&Ø‘àô ûð	úñ" Ü�H‰H�X˜uÔ%àŠðA ús9   ‚ •&E¼C/ÁBEÃ/	D#Ã8!DÄEÄD#Ä#EÅE)T)Ú__doc__r   r:   r   Ú
expanduserÚ_homer5   Úgetr   r   Úsplitr0   r   r'   r    r$   r   r   r!   r%   r*   r.   r2   rL   )r-   s   0r   ú<module>rR      s˜  ðñ÷6 à
�‰×Ñ˜3Ó€Ø—
‘
—‘˜Ó/ò 3Ø�G‰G�L‰L˜ ¨'Ó2ð ð �Ø‡Z�Z‡^�^�OÓ$ÒEÐ(E×LÑLÈSÓQñR€ð —*‘*—.‘.Ð!2Ó3ò +Ø�G‰G�L‰L˜ 	Ó*ð ð #Ð#Ø‡Z�Z‡^�^Ð%Ó&Ò4¨*×;Ñ;¸CÓ@ñA€ð —‘—‘Ð 0Ó1ò *Ø�G‰G�L‰L˜ Ó)ð ð —‘—‘Ð 0Ó1ò 3Ø�G‰G�L‰L˜ ¨'Ó2ð ð *Ö/�qªQ’Ò/€Ø-Ö3˜²’1Ò3€ò
ò
ò	ò	ò,òò,ô2ùòW 0ùÚ3s   Å4F0Å<F0ÆF5ÆF5