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/landscape/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/persist.cpython-310.pyc
o

���cR�@s�ddlZddlZddlZddlZddlmZgd�Ze�ZGdd�de	�Z
Gdd�de
�ZGdd	�d	e�ZGd
d�de�Z
e�d�jZd
d�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�
StringType)�Persist�
PickleBackend�BPickleBackend�path_string_to_tuple�path_tuple_to_string�
RootedPersist�PersistError�PersistReadOnlyErrorc@�eZdZdS)r	N��__name__�
__module__�__qualname__�rr�7/usr/lib/python3/dist-packages/landscape/lib/persist.pyr	%�r	c@r)r
Nrrrrrr
)rr
c@s�eZdZdZd(dd�Zdd�Zdd�Zd	d
�Zeee�Z	ee�Z
dd�Zd
d�Zdd�Z
d)dd�Zeefdd�Zd*dd�Zedddfdd�Zd*dd�Zd+dd�Zd,dd�Zd*d d!�Zeddfd"d#�Zd,d$d%�Zd&d'�ZdS)-raPersist a hierarchical database of key=>value pairs.

    There are three different kinds of option maps, regarding the
    persistence and priority that maps are queried.

      - hard - Options are persistent.
      - soft - Options are not persistent, and have a higher priority
           than persistent options.
      - weak - Options are not persistent, and have a lower priority
           than persistent options.

    @ivar filename: The name of the file where persist data is saved
        or None if no filename is available.

    NcCsl|durt�}||_|��|_i|_i|_d|_d|_||_||_	|dur2t
j�|�r4|�
|�dSdSdS)a�
        @param backend: The backend to use. If none is specified,
            L{BPickleBackend} will be used.
        @param filename: The default filename to save to and load from. If
            specified, and the file exists, it will be immediately
            loaded. Specifying this will also allow L{save} to be called
            without any arguments to save the persist.
        NF)r�_backend�new�_hardmap�_softmap�_weakmap�	_readonly�	_modified�_config�filename�os�path�exists�load)�self�backendrrrr�__init__?s	
�zPersist.__init__cC�|jS�N)r�r rrr�
_get_readonlyU�zPersist._get_readonlycCst|�|_dSr$)�boolr)r �flagrrr�
_set_readonlyX�zPersist._set_readonlycCr#r$�rr%rrr�
_get_modified[r'zPersist._get_modifiedcCs
d|_dS)z(Set the database status as non-modified.FNr,r%rrr�reset_modifiedas
zPersist.reset_modifiedcCs|jrtd��dS)zRAssert if the object is writable

        @raise: L{PersistReadOnlyError}
        z"Configuration is in readonly mode.N)rr
r%rrr�assert_writablees�zPersist.assert_writablecs���fdd�}tj����tj���s|�rdStd���tj���dkr+|�dSz
�j����_WdSt	yH|�rBYdStd���w)zLoad a persisted database.csX�d}tj�|�r*tj�|�dkr*z
�j�|��_WdSty)td|��wdS)N�.oldr�Broken configuration file at %sTF)	rr�isfile�getsizerrr�	Exceptionr	)�filepathold��filepathr rr�load_oldps���zPersist.load.<locals>.load_oldNzFile not found: %srr1)
rr�
expanduserr2r	r3rrrr4)r r7r8rr6rrms �zPersist.loadcCs�|dur|jdur
td��|j}tj�|�}tj�|�r$t�||d�tj�|�}|r7tj�|�s7t�	|�|j
�||j�dS)z�Save the persist to the given C{filepath}.

        If None is specified, then the filename passed during construction will
        be used.

        If the destination file already exists, it will be renamed
        to C{<filepath>.old}.
        NzNeed a filename!r0)
rr	rrr9r2�rename�dirname�isdir�makedirsr�saver)r r7r;rrrr>�s	

zPersist.savec
Cs:|tur
|j�|�}t|�}t}|}|rG|}|�d�}|j�||�}|tur@|r1|dt|��}tdt	|�t
|�t|�f��||urEn|s||urY||urW|j�|||�}|S||ura|}|S	t|�dkrvt	|d�t
ursg}	ni}	n|}	|j�|||	�}|tur�tdt	|�t	|�f��|s�	|S|}|�d�}qb)NrzCan't traverse %r (%r): %rTzCan't traverse %r with %r)�NOTHINGr�copy�list�pop�get�NotImplemented�lenr	�typer�str�set�int)
r �objr�default�setvalue�queue�marker�newobj�elem�newvaluerrr�	_traverse�sX
�������
�zPersist._traverseFcCs�t|t�r	t|�}t}|r|�|j||�}|S|r#|�|j||�}|S|r/|�|j||�}|S|�|j||�}||urO|�|j||�}||urO|�|j||�}|Sr$)�
isinstancerrr?rRrrr)r r�soft�hard�weakrN�valuerrr�	_getvalue�s$
�	��zPersist._getvaluec	CsV|�||||�}t}||urdS||urdS|j�||�}|tur)tdt|���|S)NFTzCan't check %r for containment)rXr?r�hasrDr	rF)	r rrWrTrUrVrJrN�resultrrrrY�szPersist.hascCsD|�||||�}|turgS|j�|�}|tur tdt|���|S)NzCan't return keys for %s)rXr?r�keysrDr	rF)r rrTrUrVrJrZrrrr[�szPersist.keyscCs(|�||||�}|tur|S|j�|�Sr$)rXr?rr@)r rrKrTrUrVrWrrrrC�szPersist.getcCsZ|sJ�t|t�r
t|�}|r|j}n|r|j}n
|��d|_|j}|j|||d�dS�NT)rL)	rSrrrrr/rrrR)r rrWrTrV�maprrrrH�s
zPersist.setcCs�|sJ�t|t�r
t|�}|r|j}n|r|j}n
|��d|_|j}|r7|�||�}t	|�t
ur7||vr7dS|tjf}|j|||d�dSr\)
rSrrrrr/rrrRrFrA�sys�maxsize)r rrW�uniquerTrVr]�currentrrr�add
s 
zPersist.addcCs�|sJ�t|t�r
t|�}|r|j}n|r|j}n
|��d|_|j}t}|r{||ur<|�	||dd��}|d}d}	n
|�	||�}|}d}	d}
||urb|j
�|||	�}
|
turbt
d|t|�f��|j
�|�rv||uro|}n
|dd�}n	|
S|s'|
S)NT���FzCan't remove %r from %r)rSrrrrr/rrr?rRr�removerDr	rF�empty)r rrWrTrVr]rNrJrP�isvaluerZrrrrdsD

��zPersist.removecCs�|s|s|��t|t�rt|�}t|t�rt|�}d}t}|�|||p%||�}||ur?|j|||d�|�||||�d}|S)NF)rTrVT)r/rSrrr?rXrdrH)r �oldpath�newpathrTrVrZrNrWrrr�moveBs

zPersist.movecCs
t||�S)zv
        Rebase the database hierarchy.

        @return: A L{RootedPersist} using this L{Persist} as parent.
        )r�r rrrr�root_atRs
zPersist.root_at)NNr$�FFF�NFFF�FF)r
rr�__doc__r"r&r*r-�property�readonly�modifiedr.r/rr>r?rRrXrYr[rCrHrbrdrirkrrrrr-s,


"
+

	


%rc@s�eZdZdZdd�Zedd��Zedd��Zdd�Ze	d	d	d	fd
d�Z
ddd
�Zddd�Zddd�Z
ddd�Ze	d	d	fdd�Zddd�Zdd�ZdS)raxRoot a L{Persist}'s tree at a particular branch.

    This class shares the same interface of L{Persist} and provides a shortcut
    to access the nodes of a particular branch in a L{Persist}'s tree.

    The chosen branch will be viewed as the root of the tree of the
    L{RootedPersist} and all operations will be forwarded to the parent
    L{Persist} as appropriate.
    cCs(||_t|t�rt|�|_dS||_dS)z�
        @param parent: the parent L{Persist}.
        @param root: a branch of the parent L{Persist}'s tree, that
            will be used as root of this L{RootedPersist}.
        N)�parentrSrr�root)r rsrtrrrr"fs

zRootedPersist.__init__cC�|jjSr$)rsrqr%rrr�<lambda>r�zRootedPersist.<lambda>cCrur$)rsrrr%rrrrvsrwcCs|j��dSr$)rsr/r%rrrr/ur+zRootedPersist.assert_writableFcC�,t|t�r	t|�}|j�|j|||||�Sr$)rSrrrsrYrt)r rrWrTrUrVrrrrYx�
zRootedPersist.hascC�*t|t�r	t|�}|j�|j||||�Sr$)rSrrrsr[rt)r rrTrUrVrrrr[}�
zRootedPersist.keysNcCrxr$)rSrrrsrCrt)r rrKrTrUrVrrrrC�ryzRootedPersist.getcCrzr$)rSrrrsrHrt�r rrWrTrVrrrrH�r{zRootedPersist.setcCrxr$)rSrrrsrbrt)r rrWr`rTrVrrrrb�ryzRootedPersist.addcCrzr$)rSrrrsrdrtr|rrrrd�r{zRootedPersist.removecCsBt|t�r	t|�}t|t�rt|�}|j�|j||j|||�Sr$)rSrrrsrirt)r rgrhrTrVrrrri�s

�zRootedPersist.movecCs$t|t�r	t|�}|j�|j|�Sr$)rSrrrsrkrtrjrrrrk�s
zRootedPersist.root_atrlrmrn)r
rrror"rprqrrr/r?rYr[rCrHrbrdrirkrrrrr[s





rz(\[-?\d+\])|(?<!\\)\.c	Cs�d|vrd|vr|fSg}t|�}|D]4}|rG|ddkr>|ddkr>z
|�t|dd���Wqty=td|��w|�|�dd��qt|�S)	a�Convert a L{Persist} path string to a path tuple.

    Examples:

        >>> path_string_to_tuple("ab")
        ("ab",)
        >>> path_string_to_tuple("ab.cd")
        ("ab", "cd"))
        >>> path_string_to_tuple("ab[0][1]")
        ("ab", 0, 1)
        >>> path_string_to_tuple("ab[0].cd[1]")
        ("ab", 0, "cd", 1)

    Raises L{PersistError} if the given path string is invalid.
    �.�[rrc�]�zInvalid path index: %r�\.)�
_splitpath�appendrI�
ValueErrorr	�replace�tuple)rrZ�tokens�tokenrrrr�s��rcCsPg}|D]}t|�tur|dd|7<q|�t|��dd��qd�|�S)Nrcz[%d]r}r�)rFrIr�rGr��join)rrZrPrrrr�s
rc@sdeZdZdZdd�Zdd�Zdd�Zefdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�BackendaD
    Base class for L{Persist} backends implementing hierarchical storage
    functionality.

    Each node of the hierarchy is an object of type C{dict}, C{list}
    or C{tuple}. A node can have zero or more children, each child can be
    another node or a leaf value compatible with the backend's serialization
    mechanism.

    Each child element is associated with a unique key, that can be used to
    get, set or remove the child itself from its containing node. If the node
    object is of type C{dict}, then the child keys will be the keys of the
    dictionary, otherwise if the node object is of type C{list} or C{tuple}
    the child element keys are the indexes of the available items, or the value
    of items theselves.

    The root node object is always a C{dict}.

    For example:

        >>> backend = Backend()
        >>> root = backend.new()
        >>> backend.set(root, "foo", "bar")
        'bar'
        >>> egg = backend.set(root, "egg", [1, 2, 3])
        >>> backend.set(egg, 0, 10)
        10
        >>> root
        {'foo': 'bar', 'egg': [10, 2, 3]}
    cC�t�r$��NotImplementedErrorr%rrrr��zBackend.newcCr�r$r�)r r7rrrr�r�zBackend.loadcCr�r$r�)r r7r]rrrr>�r�zBackend.savecCs�t|�tur|�||�}|St|�ttfvr<t|�tur0z||}W|Sty/|}Y|Sw||vr8|}|S|}|St}|S)z(Lookup a child in the given node object.)rF�dictrCr�rArI�
IndexErrorrD)r rJrP�_markerrOrrrrC�s&
�
	����zBackend.getcCs�t|�tur|}||<|St|�turDt|�turDt|�}||kr*|�d�|}n|dkr<t|�|kr<|�dd�d}|}||<|St}|S)z:Set the value of the given child in the given node object.Nr)	rFr�rArIrEr��abs�insertrD)r rJrPrWrO�lenobjrrrrHs�
�zBackend.setcs�d}t|�tur�|vr|�=d}|St|�turI|s4t��tur4z|�=d}W|Sty3Y|Sw�|vrG�fdd�|D�|dd�<d}|St}|S)z�Remove a the given child in the given node object.

        @param isvalue: In case the node object is a C{list}, a boolean
            indicating if C{elem} is the index of the child or the value
            of the child itself.
        FTcsg|]}|�kr|�qSrr)�.0�x�rPrr�
<listcomp>1sz"Backend.remove.<locals>.<listcomp>N)rFr�rArIr�rD)r rJrPrfrZrr�rrds,
����zBackend.removecCst|�ttfvr
t�|�S|S)zCopy a node or a value.)rFr�rAr@�deepcopy)r rWrrrr@7s
zBackend.copycCs|S)z.Whether the given node object has no children.r)r rJrrrre=sz
Backend.emptycCst|dd�}|r||�StS)z?Whether the given node object contains the given child element.�__contains__N)�getattrrD)r rJrP�containsrrrrYAszBackend.hascCs2t|dd�}|r|�St|�turtt|��StS)z?Return the keys of the child elements of the given node object.r[N)r�rFrA�rangerErD)r rJr[rrrr[HszBackend.keysN)r
rrrorrr>r?rCrHrdr@rerYr[rrrrr��sr�c@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcC�ddlm}||_dS)Nr)�cPickle)�landscape.lib.compatr��_pickle)r r�rrrr"T�
zPickleBackend.__init__cC�iSr$rr%rrrrXr�zPickleBackend.newcCs:t|d��}|j�|�Wd�S1swYdS�N�rb)�openr�r�r r7�fdrrrr[s
$�zPickleBackend.loadcCs@t|d��}|j�||d�Wd�dS1swYdS)N�wb�)r�r��dump�r r7r]r�rrrr>_s"�zPickleBackend.saveN�r
rrr"rrr>rrrrrR�
rc@r�)
rcCr�)Nr)�bpickle)�
landscape.libr��_bpickle)r r�rrrr"fr�zBPickleBackend.__init__cCr�r$rr%rrrrjr�zBPickleBackend.newcCs>t|d��}|j�|���Wd�S1swYdSr�)r�r��loads�readr�rrrrms$�zBPickleBackend.loadcCsBt|d��}|�|j�|��Wd�dS1swYdS)Nr�)r��writer��dumpsr�rrrr>qs"�zBPickleBackend.saveNr�rrrrrdr�r)rr^r@�re�twisted.python.compatr�__all__�objectr?r4r	r
rr�compile�splitr�rrr�rrrrrr�<module>s(0I 


Spamworldpro Mini