Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/persisted/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/persisted/__pycache__/dirdbm.cpython-310.pyc
o

�bi'�@s�dZddlZddlZddlZddlZddlmZzeWney'e	ZYnwGdd�d�Z
Gdd�de
�Zddd	�Z	gd
�ZdS)a�
DBM-style interface to a directory.

Each key is stored as a single file.  This is not expected to be very fast or
efficient, but it's good for easy debugging.

DirDBMs are *not* thread-safe, they should only be accessed by one thread at
a time.

No files should be placed in the working directory of a DirDBM save those
created by the DirDBM itself!

Maintainer: Itamar Shtull-Trauring
�N)�FilePathc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd-dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZdS).�DirDBMz�
    A directory with a DBM interface.

    This class presents a hash-like interface to a directory of small,
    flat files. It can only use strings as keys or values.
    cCs�tj�|�|_t|�|_|j��s|j��dSt�|j�	d�j�D]}t�
|�q"t�|j�	d�j�}|D]}|dd�}tj�|�rJt�
|�q6t�||�q6dS)zb
        @type name: str
        @param name: Base path to use for the directory storage.
        z*.newz*.rplN���)
�os�path�abspath�dnamer�
_dnamePath�isdir�createDirectory�glob�child�remove�exists�rename)�self�name�f�replacements�old�r�:/usr/lib/python3/dist-packages/twisted/persisted/dirdbm.py�__init__,s


�zDirDBM.__init__cCst�|��dd��dd�S)z?
        Encode a key so it can be used as a filename.
        �
�_�/�-)�base64�encodebytes�replace�r�krrr�_encodeHszDirDBM._encodecCst�|�dd��dd��S)z3
        Decode a filename to get the key.
        rrrr)r�decodebytesrr rrr�_decodeO�zDirDBM._decodecCs:t|jd��
}|��}Wd�|S1swY|S)z�
        Read in the contents of a file.

        Override in subclasses to e.g. provide transparently encrypted dirdbm.
        �rbN)�_openr�read)rrr�srrr�	_readFileUs

��zDirDBM._readFilecCsDt|jd��}|�|�|��Wd�dS1swYdS)zw
        Write data to a file.

        Override in subclasses to e.g. provide transparently encrypted dirdbm.
        �wbN)r'r�write�flush)rr�datarrrr�
_writeFile_s

"�zDirDBM._writeFilecCst|j���S)zF
        @return: The number of key/value pairs in this Shelf
        )�lenr	�listdir�rrrr�__len__iszDirDBM.__len__cCs�t|�tks
td��t|�tkstd��|�|�}|j�|�}|��r)|�d�}n|�d�}z|�||�Wnt	yB|�
��w|��rK|�
�|�|�dS)z�
        C{dirdbm[k] = v}
        Create or modify a textfile in this directory

        @type k: bytes
        @param k: key to set

        @type v: bytes
        @param v: value to associate with C{k}
        �DirDBM key must be byteszDirDBM value must be bytesz.rplz.newN)�type�bytes�	TypeErrorr"r	r
r�siblingExtensionr/�
BaseExceptionr�moveTo)rr!�vr�newrrr�__setitem__os$

�zDirDBM.__setitem__cCsJt|�tks
td��|j�|�|��}z|�|�WSty$t|��w)a
        C{dirdbm[k]}
        Get the contents of a file in this directory as a string.

        @type k: bytes
        @param k: key to lookup

        @return: The value associated with C{k}
        @raise KeyError: Raised when there is no such key
        r4)	r5r6r7r	r
r"r*�OSError�KeyError)rr!rrrr�__getitem__�s�zDirDBM.__getitem__cCsRt|�tks
td��|�|�}z|j�|���WdSty(t|�	|���w)z�
        C{del dirdbm[foo]}
        Delete a file in this directory.

        @type k: bytes
        @param k: key to delete

        @raise KeyError: Raised when there is no such key
        r4N)
r5r6r7r"r	r
rr>r?r$r rrr�__delitem__�s

�zDirDBM.__delitem__cCstt|j|j������S)z9
        @return: a L{list} of filenames (keys).
        )�list�mapr$r	�asBytesModer1r2rrr�keys�r%zDirDBM.keyscCs(g}|��}|D]	}|�||�q|S)z?
        @return: a L{list} of file-contents (values).
        �rE�append)r�valsrE�keyrrr�values�s
z
DirDBM.valuescCs,g}|��}|D]}|�|||f�q|S)zL
        @return: a L{list} of 2-tuples containing key/value pairs.
        rF)r�itemsrErIrrrrK�s
zDirDBM.itemscCs.t|�tks
td��|�|�}|j�|���S)z�
        @type key: bytes
        @param key: The key to test

        @return: A true value if this dirdbm has the specified key, a false
        value otherwise.
        r4)r5r6r7r"r	r
�isfile�rrIrrr�has_key�s
zDirDBM.has_keycCs||vr
|||<|S||S)z�
        @type key: bytes
        @param key: The key to lookup

        @param value: The value to associate with key if key is not already
        associated with a value.
        r)rrI�valuerrr�
setdefault�szDirDBM.setdefaultNcCs||vr||S|S)z�
        @type key: bytes
        @param key: The key to lookup

        @param default: The value to return if the given key does not exist

        @return: The value associated with C{key} or C{default} if not
        L{DirDBM.has_key(key)}
        r)rrI�defaultrrr�get�s
z
DirDBM.getcCs
|�|�S)z)
        @see: L{DirDBM.has_key}
        )rNrMrrr�__contains__�s
zDirDBM.__contains__cCs|��D]\}}|||<qdS)z�
        Add all the key/value pairs in L{dict} to this dirdbm.  Any conflicting
        keys will be overwritten with the values from L{dict}.

        @type dict: mapping
        @param dict: A mapping of key/value pairs to add to this dirdbm.
        N)rK)r�dictrI�valrrr�update�s
�z
DirDBM.updatecCsHt|�}||jksJ�|�|j�}|��|��D]}||||<q|S)a<
        Copy the contents of this dirdbm to the dirdbm at C{path}.

        @type path: L{str}
        @param path: The path of the dirdbm to copy to.  If a dirdbm
        exists at the destination path, it is cleared first.

        @rtype: C{DirDBM}
        @return: The dirdbm this dirdbm was copied to.
        )rr	�	__class__r�clearrE)rr�dr!rrr�copyTo
sz
DirDBM.copyTocCs|��D]}||=qdS)z<
        Delete all key/value pairs in this dirdbm.
        N)rEr rrrrXs�zDirDBM.clearcCsdS)zL
        Close this dbm: no-op, for dbm-style interface compliance.
        Nrr2rrr�close%szDirDBM.closecCs>t|�tks
td��|j�|�|��}|��r|��St|��)z�
        Returns modification time of an entry.

        @return: Last modification date (seconds since epoch) of entry C{key}
        @raise KeyError: Raised when there is no such key
        r4)	r5r6r7r	r
r"rL�getModificationTimer?)rrIrrrrr\*szDirDBM.getModificationTime)N)�__name__�
__module__�__qualname__�__doc__rr"r$r*r/r3r=r@rArErJrKrNrPrRrSrVrZrXr[r\rrrrr$s.

"



rc@s eZdZdZdd�Zdd�ZdS)�Shelfz�
    A directory with a DBM shelf interface.

    This class presents a hash-like interface to a directory of small,
    flat files. Keys must be strings, but values can be any given object.
    cCst�|�}t�|||�dS)z�
        C{shelf[foo] = bar}
        Create or modify a textfile in this directory.

        @type k: str
        @param k: The key to set

        @param v: The value to associate with C{key}
        N)�pickle�dumpsrr=)rr!r;rrrr=Bs

zShelf.__setitem__cCst�t�||��S)a
        C{dirdbm[foo]}
        Get and unpickle the contents of a file in this directory.

        @type k: bytes
        @param k: The key to lookup

        @return: The value associated with the given key
        @raise KeyError: Raised if the given key does not exist
        )rb�loadsrr@r rrrr@OszShelf.__getitem__N)r]r^r_r`r=r@rrrrra:s
racCst|�S)z�
    This is for 'anydbm' compatibility.

    @param file: The parameter to pass to the DirDBM constructor.

    @param flag: ignored
    @param mode: ignored
    )r)�file�flag�moderrr�open]s	rh)rhrra)NN)
r`rrrrb�twisted.python.filepathrr'�	NameErrorrhrra�__all__rrrr�<module>s"�
#

Spamworldpro Mini