[Zope3-checkins] CVS: ZODB4/ZODB - FileStorage.py:1.97
Jeremy Hylton
jeremy@zope.com
Thu, 1 Aug 2002 12:23:53 -0400
Update of /cvs-repository/ZODB4/ZODB
In directory cvs.zope.org:/tmp/cvs-serv12878/ZODB
Modified Files:
FileStorage.py
Log Message:
Code cleanup.
Use u64 in preference to U64.
Make PackError an exception instead of a string.
Undo some local variable aliases for attributes.
Remove unused arg to _load(): _stuff.
Remove assignments to unused local variables.
Add _pack_index() helper function. Alas, it's much harder to untangle
other parts of pack.
=== ZODB4/ZODB/FileStorage.py 1.96 => 1.97 === (558/658 lines abridged)
from ZODB.POSException import UndoError, POSKeyError, MultipleUndoErrors
from ZODB.TimeStamp import TimeStamp
from ZODB.lock_file import lock_file
-from ZODB.utils import t32, p64, U64, cp
+from ZODB.utils import t32, p64, u64, cp
try:
from ZODB.fsIndex import fsIndex
@@ -167,6 +167,9 @@
class FileStorageError(POSException.StorageError):
pass
+class PackError(FileStorageError):
+ pass
+
class FileStorageFormatError(FileStorageError):
"""Invalid file format
@@ -351,7 +354,7 @@
while 1:
seek(pos-8)
rstl=read(8)
- tl=U64(rstl)
+ tl=u64(rstl)
pos=pos-tl-8
if pos < 4: return 0
seek(pos)
@@ -371,8 +374,8 @@
seek(opos)
h=read(DATA_HDR_LEN)
oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h)
- tloc=U64(stloc)
- plen=U64(splen)
+ tloc=u64(stloc)
+ plen=u64(splen)
dlen=DATA_HDR_LEN+(plen or 8)
if vlen: dlen=dlen+(16+vlen)
@@ -508,14 +511,14 @@
# We haven't checked this transaction before,
# get it's status.
t = tloc
- self._file.seek(U64(t) + 16)
+ self._file.seek(u64(t) + 16)
tstatus = self._file.read(1)
if tstatus != 'u':
# Yee ha! We can quit
break
spos = h[-8:]
[-=- -=- -=- 558 lines omitted -=- -=- -=-]
def next(self, index=0):
if self._file is None:
@@ -2155,7 +2141,7 @@
warn("%s time-stamp reduction at %s", self._file.name, pos)
self._ltid=tid
- tl=U64(stl)
+ tl=u64(stl)
if pos+(tl+8) > self._file_size or status=='c':
# Hm, the data were truncated or the checkpoint flag wasn't
@@ -2176,7 +2162,7 @@
# the end and read what should be the transaction
# length of the last transaction.
seek(-8, 2)
- rtl=U64(read(8))
+ rtl=u64(read(8))
# Now check to see if the redundant transaction length is
# reasonable:
if self._file_size - rtl < pos or rtl < TRANS_HDR_LEN:
@@ -2195,7 +2181,7 @@
if self._stop is not None:
LOG("ZODB FS", BLATHER,
("tid %x > stop %x ? %d" %
- (U64(tid), U64(self._stop), tid > self._stop)))
+ (u64(tid), u64(self._stop), tid > self._stop)))
if self._stop is not None and tid > self._stop:
raise IndexError, index
@@ -2263,16 +2249,15 @@
seek(pos)
h=read(DATA_HDR_LEN)
oid,serial,sprev,stloc,vlen,splen = unpack(">8s8s8s8sH8s", h)
- prev=U64(sprev)
- tloc=U64(stloc)
- plen=U64(splen)
+ ##prev=u64(sprev)
+ tloc=u64(stloc)
+ plen=u64(splen)
dlen=DATA_HDR_LEN+(plen or 8)
if vlen:
dlen=dlen+(16+vlen)
- seek(8,1)
- pv=U64(read(8))
+ seek(16, 1)
version=read(vlen)
else:
version=''