File: //usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyo
�
��abc @` s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l m
Z m Z
d e f d � � YZ d e f d � � YZ d � Z d
� Z e j d e � d � � Z e j d
� � Z d � Z d � Z d S( s�
merged implementation of the cache provider
the name cache was not chosen to ensure pluggy automatically
ignores the external pytest-cache
i ( t absolute_importt divisiont print_functionN( t sept altsept Cachec B` sD e Z d � Z e d � � Z d � Z d � Z d � Z d � Z RS( c C` s� | | _ t j | � | _ | j j j d � | _ | j d � r~ | j d � | j j � rn | j j � n | j j
� n d S( Nt cachet
cacheclears clearing cachedir( t configR t cache_dir_from_configt _cachedirt tracet roott gett getoptiont checkt removet mkdir( t selfR ( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyt __init__ s
c C` si | j d � } t j j | � } t j j | � } t j j | � rU t j j | � S| j j | � Sd S( Nt cache_dir(
t getinit ost patht
expandusert
expandvarst isabst pyt localt rootdirt join( R R ( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyR s c C` sF t | k s$ t d k r3 t | k r3 t d � � n | j j d | � S( s� return a directory path object with the given name. If the
directory does not yet exist, it will be created. You can use it
to manage files likes e. g. store/retrieve database
dumps across test sessions.
:param name: must be a string not containing a ``/`` separator.
Make sure the name contains your plugin or application
identifiers to prevent clashes with other cache users.
s. name is not allowed to contain path separatorst dN( t _sept _altsept Nonet
ValueErrorR
t
ensure_dir( R t name( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyt makedir$ s
$c C` s | j j d | j d � � S( Nt vt /( R
R t split( R t key( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyt
_getvaluepath2 s c C` ss | j | � } | j � ro y) | j d � � } t j | � SWd QXWqo t k
rk | j d | f � qo Xn | S( s� return cached value for the given key. If no value
was yet cached or the value cannot be read, the specified
default is returned.
:param key: must be a ``/`` separated value. Usually the first
name is the name of your plugin or your application.
:param default: must be provided in case of a cache-miss or
invalid cache values.
t rNs cache-invalid at %s( R+ R t opent jsont loadR# R ( R R* t defaultR t f( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyR
5 s
c C` s� | j | � } y | j � j � WnD t j j t j j f k
ri | j j d d d d | f � d SXy | j d � } Wn7 t j j
k
r� | j j d d d d | f � nA X| �8 | j d | | f � t j
| | d d
d t �Wd QXd S( sP save value for the given key.
:param key: must be a ``/`` separated value. Usually the first
name is the name of your plugin or your application.
:param value: must be of any combination of basic
python types, including nested types
like e. g. lists of dictionaries.
t codet I9t messages could not create cache path %sNt ws cache could not write path %ss cache-write %s: %rt indenti t sort_keys( R+ t dirpathR$ R t errort EEXISTt EACCESR t warnR- t ENOTDIRR R. t dumpt True( R R* t valueR R1 ( ( s9 /usr/lib/python2.7/site-packages/_pytest/cacheprovider.pyt setI s ( t __name__t
__module__R t staticmethodR R&