ó
q]c           @   s  d  Z  d d l Z d d l Z d d l Z e j j Z d „  Z i  Z d „  Z	 d „  Z
 d „  Z d „  Z e j d k rÉ e j j d	 d ƒ Z e r¨ e e d
 ƒ g Z qÕ e j j e j d d
 ƒ g Z n d d g Z e j j e j d d
 ƒ g Z d „  Z e j d k rJe j j d	 d ƒ Z e rAe j j e d
 ƒ g Z qVg  Z n d d g Z e j j e j d d
 ƒ g Z d „  Z d S(   s   Path utility functions.iÿÿÿÿNc          C   s(   t  j j d ƒ }  t  j j |  ƒ }  |  S(   s'   Get the real path of the home directoryt   ~(   t   ost   patht
   expandusert   realpath(   t   homedir(    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   get_home_dir   s    c         C   sC   y t  |  SWn0 t k
 r> t j d |  d ƒ } t  |  <| SXd S(   s   Make or reuse a temporary directory.

    If this is called with the same name in the same process, it will return
    the same directory.
    t   prefixt   -N(   t   _dtempst   KeyErrort   tempfilet   mkdtemp(   t   namet   d(    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   _mkdtemp_once   s
    c          C   sO   t  j }  t ƒ  } |  j d ƒ r+ t d ƒ S|  j d ƒ rB |  d St | d ƒ S(   s   Get the Jupyter config directory for this platform and user.
    
    Returns JUPYTER_CONFIG_DIR if defined, else ~/.jupyter
    t   JUPYTER_NO_CONFIGs   jupyter-clean-cfgt   JUPYTER_CONFIG_DIRs   .jupyter(   R   t   environR   t   getR   t   pjoin(   t   envt   home_dir(    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   jupyter_config_dir(   s    		
c          C   sÖ   t  j }  |  j d ƒ r  |  d St ƒ  } t j d k rN t  j j | d d ƒ St  j d k r˜ t  j j d d ƒ } | r… t
 | d ƒ St
 t ƒ  d ƒ Sn: |  j d	 d ƒ } | sÅ t
 | d
 d ƒ } n  t
 | d ƒ Sd S(   sÀ   Get the config directory for Jupyter data files.
    
    These are non-transient, non-configuration files.
    
    Returns JUPYTER_DATA_DIR if defined, else a platform-appropriate path.
    t   JUPYTER_DATA_DIRt   darwint   Libraryt   Jupytert   ntt   APPDATAt   jupytert   datat   XDG_DATA_HOMEs   .localt   shareN(   R   R   R   R   t   syst   platformR   t   joinR   t   NoneR   R   (   R   t   homet   appdatat   xdg(    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   jupyter_data_dir:   s    		c          C   s0   t  j }  |  j d ƒ r  |  d St t ƒ  d ƒ S(   sç   Return the runtime dir for transient jupyter files.
    
    Returns JUPYTER_RUNTIME_DIR if defined.
    
    The default is now (data_dir)/runtime on all platforms;
    we no longer use XDG_RUNTIME_DIR after various problems.
    t   JUPYTER_RUNTIME_DIRt   runtime(   R   R   R   R   R)   (   R   (    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   jupyter_runtime_dirX   s    	R   t   PROGRAMDATAR   R!   s   /usr/local/share/jupyters   /usr/share/jupyterc          G   s¾   g  } t  j j d ƒ rE | j d „  t  j d j t  j ƒ Dƒ ƒ n  | j t ƒ  ƒ x* t D]" } | t	 k r\ | j | ƒ q\ q\ W| j t	 ƒ |  rº g  | D] } t
 | |  Œ ^ qœ } n  | S(   s™  Return a list of directories to search for data files
    
    JUPYTER_PATH environment variable has highest priority.
    
    If ``*subdirs`` are given, that subdirectory will be added to each element.
    
    Examples:
    
    >>> jupyter_path()
    ['~/.local/jupyter', '/usr/local/share/jupyter']
    >>> jupyter_path('kernels')
    ['~/.local/jupyter/kernels', '/usr/local/share/jupyter/kernels']
    t   JUPYTER_PATHc         s   s!   |  ] } | j  t j ƒ Vq d  S(   N(   t   rstripR   t   sep(   t   .0t   p(    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pys	   <genexpr>Š   s   (   R   R   R   t   extendt   splitt   pathsept   appendR)   t   ENV_JUPYTER_PATHt   SYSTEM_JUPYTER_PATHR   (   t   subdirst   pathsR2   (    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   jupyter_pathw   s    !%s   /usr/local/etc/jupyters   /etc/jupytert   etcc          C   sŸ   t  ƒ  g }  t j j d ƒ r" |  St j j d ƒ ra |  j d „  t j d j t j ƒ Dƒ ƒ n  x* t D]" } | t k rh |  j	 | ƒ qh qh W|  j t ƒ |  S(   s:   Return the search path for Jupyter config files as a list.R   t   JUPYTER_CONFIG_PATHc         s   s!   |  ] } | j  t j ƒ Vq d  S(   N(   R/   R   R0   (   R1   R2   (    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pys	   <genexpr>´   s   (
   R   R   R   R   R3   R4   R5   t   ENV_CONFIG_PATHt   SYSTEM_CONFIG_PATHR6   (   R:   R2   (    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   jupyter_config_path«   s    !(   t   __doc__R   R"   R   R   R$   R   R   R	   R   R   R)   R,   R   R   R   R%   t   programdataR8   R   R7   R;   R?   R>   R@   (    (    (    s1   lib/python2.7/site-packages/jupyter_core/paths.pyt   <module>   s8   
					!		%		