Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.21.40.24
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : shelve.cpython-32.pyc
l
��bc@s�dZddlmZmZddlmZddlZddddgZGd	�d
ej�Z	Gd�dej�Z
Gd�de
�ZGd
�de
�Zdddd�ZdS(u�
Manage shelves of pickled objects.

A "shelf" is a persistent, dictionary-like object.  The difference
with dbm databases is that the values (not the keys!) in a shelf can
be essentially arbitrary Python objects -- anything that the "pickle"
module can handle.  This includes most class instances, recursive data
types, and objects containing lots of shared sub-objects.  The keys
are ordinary strings.

To summarize the interface (key is a string, data is an arbitrary
object):

        import shelve
        d = shelve.open(filename) # open, with (g)dbm filename -- no suffix

        d[key] = data   # store data at key (overwrites old data if
                        # using an existing key)
        data = d[key]   # retrieve a COPY of the data at key (raise
                        # KeyError if no such key) -- NOTE that this
                        # access returns a *copy* of the entry!
        del d[key]      # delete data stored at key (raises KeyError
                        # if no such key)
        flag = key in d # true if the key exists
        list = d.keys() # a list of all existing keys (slow!)

        d.close()       # close it

Dependent on the implementation, closing a persistent dictionary may
or may not be necessary to flush changes to disk.

Normally, d[key] returns a COPY of the entry.  This needs care when
mutable entries are mutated: for example, if d[key] is a list,
        d[key].append(anitem)
does NOT modify the entry d[key] itself, as stored in the persistent
mapping -- it only modifies the copy, which is then immediately
discarded, so that the append has NO effect whatsoever.  To append an
item to d[key] in a way that will affect the persistent mapping, use:
        data = d[key]
        data.append(anitem)
        d[key] = data

To avoid the problem with mutable entries, you may pass the keyword
argument writeback=True in the call to shelve.open.  When you use:
        d = shelve.open(filename, writeback=True)
then d keeps a cache of all entries you access, and writes them all back
to the persistent mapping when you call d.close().  This ensures that
such usage as d[key].append(anitem) works as intended.

However, using keyword argument writeback=True may consume vast amount
of memory for the cache, and it may make d.close() very slow, if you
access many of d's entries after opening it in this way: d has no way to
check which of the entries you access are mutable and/or which ones you
actually mutate, so it must cache, and write back at close, all of the
entries that you access.  You can call d.sync() to write back all the
entries in the cache, and empty the cache (d.sync() also synchronizes
the persistent dictionary on disk, if feasible).
i(uPickleru	Unpickler(uBytesIONuShelfu
BsdDbShelfuDbfilenameShelfuopencBs@|EeZdZd�ZeZZZZZZ	d�Z
dS(u>Marker for a closed dict.  Access attempts raise a ValueError.cGstd��dS(Nu!invalid operation on closed shelf(u
ValueError(uselfuargs((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuclosedEscCsdS(Nu<Closed Dictionary>((uself((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__repr__IsN(u__name__u
__module__u__doc__uclosedu__iter__u__len__u__getitem__u__setitem__u__delitem__ukeysu__repr__(u
__locals__((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu_ClosedDictBs
	u_ClosedDictcBs�|EeZdZd
ddd�Zd�Zd�Zd�Zd
d�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
S(u�Base class for shelf implementations.

    This is initialized with a dictionary-like object.
    See the module's __doc__ string for an overview of the interface.
    uutf-8cCsF||_|dkrd}n||_||_i|_||_dS(Ni(udictuNoneu	_protocolu	writebackucacheukeyencoding(uselfudictuprotocolu	writebackukeyencoding((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__init__Ts					ccs/x(|jj�D]}|j|j�VqWdS(N(udictukeysudecodeukeyencoding(uselfuk((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__iter__^scCs
t|j�S(N(ulenudict(uself((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__len__bscCs|j|j�|jkS(N(uencodeukeyencodingudict(uselfukey((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__contains__escCs'|j|j�|jkr#||S|S(N(uencodeukeyencodingudict(uselfukeyudefault((u-/usr/local/python-3.2/lib/python3.2/shelve.pyugethscCsty|j|}Wn\tk
rot|j|j|j��}t|�j�}|jrk||j|<nYnX|S(N(	ucacheuKeyErroruBytesIOudictuencodeukeyencodingu	Unpickleruloadu	writeback(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__getitem__ms
	cCsd|jr||j|<nt�}t||j�}|j|�|j�|j|j|j	�<dS(N(
u	writebackucacheuBytesIOuPickleru	_protocoludumpugetvalueudictuencodeukeyencoding(uselfukeyuvalueufup((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__setitem__ws		
cCs=|j|j|j�=y|j|=Wntk
r8YnXdS(N(udictuencodeukeyencodingucacheuKeyError(uselfukey((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__delitem__s

cCsh|j�y|jj�Wntk
r/YnXyt�|_Wn!ttfk
rcd|_YnXdS(N(usyncudictucloseuAttributeErroru_ClosedDictu	NameErroru	TypeErroruNone(uself((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuclose�s

cCs!t|d�sdS|j�dS(Nu	writeback(uhasattruclose(uself((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__del__�scCs�|jrZ|jrZd|_x'|jj�D]\}}|||<q+Wd|_i|_nt|jd�r||jj�ndS(NusyncFT(u	writebackucacheuFalseuitemsuTrueuhasattrudictusync(uselfukeyuentry((u-/usr/local/python-3.2/lib/python3.2/shelve.pyusync�s		NF(u__name__u
__module__u__doc__uNoneuFalseu__init__u__iter__u__len__u__contains__ugetu__getitem__u__setitem__u__delitem__ucloseu__del__usync(u
__locals__((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuShelfMs
					
			
	cBsS|EeZdZdd	dd�Zd�Zd�Zd�Zd�Z	d�Z
dS(
u�Shelf implementation using the "BSD" db interface.

    This adds methods first(), next(), previous(), last() and
    set_location() that have no counterpart in [g]dbm databases.

    The actual database must be opened using one of the "bsddb"
    modules "open" routines (i.e. bsddb.hashopen, bsddb.btopen or
    bsddb.rnopen) and passed to the constructor.

    See the module's __doc__ string for an overview of the interface.
    uutf-8cCstj|||||�dS(N(uShelfu__init__(uselfudictuprotocolu	writebackukeyencoding((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__init__�scCsF|jj|�\}}t|�}|j|j�t|�j�fS(N(udictuset_locationuBytesIOudecodeukeyencodingu	Unpickleruload(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuset_location�scCsCt|j�\}}t|�}|j|j�t|�j�fS(N(unextudictuBytesIOudecodeukeyencodingu	Unpickleruload(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyunext�scCsC|jj�\}}t|�}|j|j�t|�j�fS(N(udictupreviousuBytesIOudecodeukeyencodingu	Unpickleruload(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuprevious�scCsC|jj�\}}t|�}|j|j�t|�j�fS(N(udictufirstuBytesIOudecodeukeyencodingu	Unpickleruload(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyufirst�scCsC|jj�\}}t|�}|j|j�t|�j�fS(N(udictulastuBytesIOudecodeukeyencodingu	Unpickleruload(uselfukeyuvalueuf((u-/usr/local/python-3.2/lib/python3.2/shelve.pyulast�sNF(u__name__u
__module__u__doc__uNoneuFalseu__init__uset_locationunextupreviousufirstulast(u
__locals__((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu
BsdDbShelf�s
				cBs&|EeZdZdddd�ZdS(u�Shelf implementation using the "dbm" generic dbm interface.

    This is initialized with the filename for the dbm database.
    See the module's __doc__ string for an overview of the interface.
    uccCs2ddl}tj||j||�||�dS(Ni(udbmuShelfu__init__uopen(uselfufilenameuflaguprotocolu	writebackudbm((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu__init__�sNF(u__name__u
__module__u__doc__uNoneuFalseu__init__(u
__locals__((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuDbfilenameShelf�s
uccCst||||�S(uOpen a persistent dictionary for reading and writing.

    The filename parameter is the base filename for the underlying
    database.  As a side-effect, an extension may be added to the
    filename and more than one file may be created.  The optional flag
    parameter has the same interpretation as the flag parameter of
    dbm.open(). The optional protocol parameter specifies the
    version of the pickle protocol (0, 1, or 2).

    See the module's __doc__ string for an overview of the interface.
    (uDbfilenameShelf(ufilenameuflaguprotocolu	writeback((u-/usr/local/python-3.2/lib/python3.2/shelve.pyuopen�s
F(u__doc__upickleuPickleru	UnpickleruiouBytesIOucollectionsu__all__uMutableMappingu_ClosedDictuShelfu
BsdDbShelfuDbfilenameShelfuNoneuFalseuopen(((u-/usr/local/python-3.2/lib/python3.2/shelve.pyu<module>9sW+
© 2025 GrazzMean