python (3.12.0)

(root)/
lib/
python3.12/
dbm/
__pycache__/
dumb.cpython-312.pyc

ˑeJ-~dZddlZddlZddlZddlZddgZ	dZ
eZGddejjZd	dZy)
aA dumb and slow but simple dbm clone.

For database spam, spam.dir contains the index (a text file),
spam.bak *may* contain a backup of the index (also a text file),
while spam.dat contains the data (a binary file).

XXX TO DO:

- seems to contain a bug when updating...

- reclaim free space (currently, space once occupied by deleted or expanded
items is never reused)

- support concurrent access (currently, if two processes take turns making
updates, they can mess up the index)

- support efficient access to large databases (currently, the whole index
is read when the database is opened, and some updates rewrite the whole index)

- support opening for read-only (flag = 'm')

NerroropeniceZdZeZeZddZdZdZdZeZ	dZ
dZdZdZ
d	Zd
ZdZdZd
ZdZdZeZdZdZeZdZdZdZy)	_Databasec|jj|}||_|dk(|_|dz|_|dz|_|dz|_d|_|j||j|y)Nrs.dirs.dats.bak)
_osfsencode_mode	_readonly_dirfile_datfile_bakfile_index_create_update)selffilebasenamemodeflags    </BuggyBox/python/3.12.0/bootstrap/lib/python3.12/dbm/dumb.py__init__z_Database.__init__0ssxx((6
#+%w.
%w.
$w.
	
TTc|dk(r>|j|j|jfD]}	tj|	t
j|jdd}|jy#t
$rYZwxYw#t
$r[|dvrt
j|jdd5}|j|jdddYy#1swYYyxYwwxYw)NnrLatin-1encodingcrw)
rrr
r	removeOSError_iorclose_chmod)rrfilenamefs    rrz_Database._createJs3;!]]DMM4==I
JJx(
	i@A
GGI
	+:%$--yA
+QDMM*
+
+
+	+s;A8"B8	BB0C+7CC+C'	"C+'C+cjd|_i|_	tj|jdd}|5|D]J}|j}t
j|\}}|jd}||j|<L	dddy#1swYyxYw#t$r|dvrd|_YywxYw)NFrrrrT)
	_modifiedrr$rr
rstrip_astliteral_evalencoder#)rrr(linekeypos_and_siz_pairs      rrz_Database._update]s	8i@A
88D;;=D,0,=,=d,C)C)**Y/C'7DKK$	8
8
8
8	":%!DN	"s"BABBB21B2cf|j|jsy	|jj|j	|jj
|j|j|jj|jdd5}|j|j|jjD]-\}}|jdd|d}|j|/	dddy#t
$rYwxYw#t
$rYwxYw#1swYyxYw)Nr!rr, 
)rr*r	unlinkrr#renamer
r$rr&itemsdecodewrite)rr(r0r1entrys     r_commitz_Database._commitqs;;dnn	HHOODMM*	HHOODMM4==9XX]]4==#	]
B	aKK

&)-):):)<
%%'*jj&;=MN	
				
				s0%D	0DA&D'		DD	D$#D$'D0c2|jtdyN"DBM object has already been closed)rrrs r_verify_openz_Database._verify_opens;;<==rc<t|tr|jd}|j|j|\}}tj|jd5}|j||j|}ddd|S#1swYSxYw)Nutf-8rb)

isinstancestrr.r@rr$rrseekread)rr0possizr(dats      r__getitem__z_Database.__getitem__sc3**W%C;;s#S
XXdmmT
*	a
FF3K&&+C	
	
s$#BBcdtj|jd5}|jddt	|j}|tzdz
tztz}|jd||z
z|}|j|dddt|fS#1swYxYw)Nrb+r)	r$rrrFinttell
_BLOCKSIZEr9len)rvalr(rHnposs     r_addvalz_Database._addvals
XXdmmU
+	q
FF1aLaffh-C:%)j8JFD
GGE48$%C
GGCL
	SX		sA0B&&B/ctj|jd5}|j||j	|ddd|t|fS#1swYxYw)NrM)r$rrrFr9rT)rrHrUr(s    r_setvalz_Database._setvalsQ
XXdmmU
+	q
FF3K
GGCL	SX		s#AA"c||j|<tj|jdd5}|j	|j|j|j
dd|ddddy#1swYyxYw)Narrr3r4)rr$rr
r&r9r8)rr0r1r(s    r_addkeyz_Database._addkeysj+C
XXdmmS9
=	LKK

&
GG#**Y"79IJK	L	L	LsAA==Bc|jrtdt|tr|j	d}n!t|t
tfstdt|tr|j	d}n!t|t
tfstd|jd|_	||jvr"|j||j|y|j|\}}|tzdz
tz}t|tzdz
tz}||kr |j|||j|<y|j||j|<y)N'The database is opened for reading onlyrBzkeys must be bytes or stringszvalues must be bytes or stringsTrO)rrrDrEr.bytes	bytearray	TypeErrorr@r*rr\rWrSrTrY)rr0rUrHrI	oldblocks	newblockss       r__setitem__z_Database.__setitem__s+>>ABBc3**W%CC%!34;<<c3**W%CC%!34=>>dkk!LLdll3/0{{3'HCz)A-*<ISJ.2zAII%#'<<S#9C 
$(<<#4C rc|jrtdt|tr|j	d}|jd|_|j|=|jy)Nr^rBT)	rrrDrEr.r@r*rr;rr0s  r__delitem__z_Database.__delitem__sW>>ABBc3**W%CKK
	
rc`	t|jS#t$r
tddwxYwr=)listrrarr?s rkeysz_Database.keys6	H$$	H<=4G	H-c|j|jjDcgc]	}|||fc}Scc}wN)r@rrjrfs  rr7z_Database.itemss8,0KK,<,<,>?Sd3i ???s>ct|tr|jd}	||jvS#t$r|jtddwxYw)NrBr>)rDrEr.rrarrfs  r__contains__z_Database.__contains__sXc3**W%C	$++%%	{{"@AtK		s	
1#Ac`	t|jS#t$r
tddwxYwr=)iterrrarr?s riterkeysz_Database.iterkeysrkrlc`	t|jS#t$r
tddwxYwr=)rTrrarr?s r__len__z_Database.__len__s6	Ht{{##	H<=4G	Hrlc	|jdx|_x|_x|_|_y#dx|_x|_x|_|_wxYwrn)r;rrr
rr?s rr%z_Database.closesJ	OLLNJNNDKN$-N$-$-$NDKN$-N$-$-s	/A
cP|jj||jyrn)r	chmodr)rfiles  rr&z_Database._chmodstTZZ(rc|Srnr?s r	__enter__z_Database.__enter__src$|jyrn)r%)rargss  r__exit__z_Database.__exit__s

rN)r )__name__
__module____qualname__r	r$rrrr;syncr@rKrWrYr\rdrgrjr7rprs__iter__rur%__del__r&r|rr{rrrr#sC

C4&8(2D>L5J
H@	H
HHOG)rrc	tjd}tj|||z}|dvrtdt	|||S#t$rY(wxYw)aEOpen the database file, filename, and return corresponding object.

    The flag argument, used to control how the database is opened in the
    other DBM implementations, supports only the semantics of 'c' and 'n'
    values.  Other values will default to the semantics of 'c' value:
    the database will always opened for update and will be created if it
    does not exist.

    The optional mode argument is the UNIX mode of the file, used only when
    the database has to be created.  It defaults to octal code 0o666 (and
    will be modified by the prevailing umask).

    r)rr!r rz)Flag must be one of 'r', 'w', 'c', or 'n')r)r	umaskAttributeError
ValueErrorr)ryrrums    rrr#sd 
YYq\		"
s|''DEET4d++

s*A	AA)r i)__doc__astr,ior$osr	collections.abccollections__all__rSr#rabcMutableMappingrrr{rr<module>rsJ.F


}..}@,r