HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/persisted/__pycache__/sob.cpython-38.pyc
U


W[M�@s�dZddlmZmZddlZddlZzddlZWnek
rLddlZYnXddl	m
Z
mZddlm
Z
ddlmZmZGdd�de�Zee�Gd	d
�d
��ZeZGdd�de
j�Zd
d�Zdd�Zdd�Zddd
dddgZdS)z`
Save and load Small OBjects to and from files, using various formats.

Maintainer: Moshe Zadka
�)�division�absolute_importN)�log�runtime)�styles)�implementer�	Interfacec@s"eZdZdZdd�Zddd�ZdS)�IPersistablez9An object which can be saved in several formats to a filecCsdS�zWSet desired format.

        @type style: string (one of 'pickle' or 'source')
        N���stylerr�7/usr/lib/python3/dist-packages/twisted/persisted/sob.py�setStyleszIPersistable.setStyleNcCsdS)�xSave object to file.

        @type tag: string
        @type filename: string
        @type passphrase: string
        Nr)�tag�filename�
passphraserrr�save%szIPersistable.save)NNN)�__name__�
__module__�__qualname__�__doc__rrrrrrr	sr	c@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	dS)�
Persistent�picklecCs||_||_dS)N)�original�name)�selfrrrrr�__init__3szPersistent.__init__cCs
||_dSr
r)rr
rrrr7szPersistent.setStylecCs\|r|}|d}nB|r8d|j||f}d|j||f}nd|j|f}d|j|f}||fS)Nz-2z
%s-%s-2.%sz%s-%s.%sz%s-2.%sz%s.%s)r)rr�extr�	finalnamerrr�_getFilename>s
zPersistent._getFilenamec	Cs&t|d��}||j|�W5QRXdS)N�wb)�openr)rr�dumpFunc�frrr�	_saveTempJszPersistent._saveTempcCs0|jdkrddlm}d}ndd�}d}||fS)N�sourcer)�
jellyToSourceZtascSst�||d�dS)N�)r�dump)�obj�filerrrr$Ssz&Persistent._getStyle.<locals>.dumpFuncZtap)r
�twisted.persisted.aotr()rr$rrrr�	_getStyleNs
zPersistent._getStyleNcCs�|��\}}|dk	r$td��d|}|�|||�\}}t�d|jd|d�|�||�tjdkr~t	j
�|�r~t	�|�t	�
||�t�d�dS)	rNzpassphrase must be None�ezSaving z application to z...Zwin32zSaved.)r.�	TypeErrorr!r�msgrr&rZplatformType�os�path�isfile�remove�rename)rrrrrr$r rrrrXs
zPersistent.save)NNN)
rrrr
rrr!r&r.rrrrrr.s
rc@s eZdZdZdd�Zdd�ZdS)�_EverythingEphemeralrcCs
||_dS)zS
        @param mainMod: The '__main__' module that this class will proxy.
        N)�mainMod)rr8rrrrrsz_EverythingEphemeral.__init__cCsLzt|j|�WStk
rF|jr(�nt�d|�t��YSYnXdS)Nz#Warning!  Loading from __main__: %s)�getattrr8�AttributeError�initRunrr1r�	Ephemeral)r�keyrrr�__getattr__xsz _EverythingEphemeral.__getattr__N)rrrr;rr>rrrrr7nsr7c
Cs�d}|dkrddlm}ntjd}}t||�}ttjd�}|tjd<d|_|�"z||�}W5|j	tjd<XW5QRXt
��d|_t|d�}|dk	r�|�
|�|S)	z�Load an object from a file.

    Deserialize an object from a file. The file can be encrypted.

    @param filename: string
    @param style: string (one of 'pickle' or 'source')
    �rr'r)�unjellyFromSource�rb�__main__�N)r-r@r�loadr#r7�sys�modulesr;r8rZ	doUpgrader	r)rr
�mode�_load�fpZee�valueZpersistablerrrrD�s$



rDc	CsJt|d��}|��}W5QRXd|i}t||d�}t|||�||}|S)z�Load the value of a variable in a Python file.

    Run the contents of the file in a namespace and return the result of the
    variable named C{variable}.

    @param filename: string
    @param variable: string
    r?�__file__�exec)r#�read�compile�eval)rZvariableZfileObj�data�dZcodeObjrJrrr�loadValueFromFile�s	rRcCs(tj�|�d}dddddddd�|S)NrC�pythonrr')z.tacz.etacz.pyz.tapz.etapz.tasz.etas)r2r3�splitext)rrrrr�	guessType�s��rU�
Persistant)rZ
__future__rrr2rEZcPickler�ImportErrorZtwisted.pythonrrZtwisted.persistedrZzope.interfacerrr	rrVr<r7rDrRrU�__all__rrrr�<module>s,=!�