scripts: Renamed lookupleaf -> lookupnext_ to match lfs3.c
- lookupleaf -> lookupnext_ - namelookupleaf -> namelookup_ I want to move away from lookupleaf usage in general in the dbg scripts, like we have in lfs3.c, but I also just really don't want to touch these scripts again unless I need to. They've been useful, but also a big time sink. Maybe I should actually learn Python's new type system. That would probably help here...
This commit is contained in:
+30
-30
@@ -1171,7 +1171,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1230,7 +1230,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1250,11 +1250,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1295,7 +1295,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1390,7 +1390,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1413,7 +1413,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1461,7 +1461,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1875,7 +1875,7 @@ class Mtree:
|
||||
return cls(bd, mrootchain, mtree,
|
||||
mbits=mbits)
|
||||
|
||||
def _lookupleaf(self, mid, *,
|
||||
def _lookupnext_(self, mid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not isinstance(mid, Mid):
|
||||
@@ -1910,8 +1910,8 @@ class Mtree:
|
||||
|
||||
# mtree? lookup in mtree
|
||||
else:
|
||||
# need to do two steps here in case lookupleaf stops early
|
||||
r = self.mtree.lookupleaf(mid.mid,
|
||||
# need to do two steps here in case lookupnext_ stops early
|
||||
r = self.mtree.lookupnext_(mid.mid,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -1955,13 +1955,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def lookupleaf(self, mid, *,
|
||||
def lookupnext_(self, mid, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _lookupleaf, this just helps
|
||||
# most of the logic is in _lookupnext_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._lookupleaf(mid,
|
||||
r = self._lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1987,7 +1987,7 @@ class Mtree:
|
||||
mid = self.mid(mid)
|
||||
|
||||
# lookup the relevant mdir
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2047,7 +2047,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2225,7 +2225,7 @@ class Mtree:
|
||||
if not isinstance(mid, Mid):
|
||||
mid = self.mid(mid)
|
||||
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2251,7 +2251,7 @@ class Mtree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def _namelookupleaf(self, did, name, *,
|
||||
def _namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if path or depth:
|
||||
@@ -2277,8 +2277,8 @@ class Mtree:
|
||||
|
||||
# mtree? find name in mtree
|
||||
else:
|
||||
# need to do two steps here in case namelookupleaf stops early
|
||||
r = self.mtree.namelookupleaf(did, name,
|
||||
# need to do two steps here in case namelookup_ stops early
|
||||
r = self.mtree.namelookup_(did, name,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -2322,13 +2322,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _namelookupleaf, this just helps
|
||||
# most of the logic is in _namelookup_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._namelookupleaf(did, name,
|
||||
r = self._namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2351,7 +2351,7 @@ class Mtree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# lookup the relevant mdir
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3322,7 +3322,7 @@ class Lfs3:
|
||||
mbid, mrid = mid.mbid, mid.mrid + 1
|
||||
if mrid == mdir.weight:
|
||||
mbid, mrid = mbid + (1 << self.mbits), 0
|
||||
mdir = self.mtree.lookupleaf(mbid)
|
||||
mdir = self.mtree.lookupnext_(mbid)
|
||||
if mdir is None:
|
||||
break
|
||||
# lookup name and adjust rid if necessary, you don't
|
||||
@@ -3546,7 +3546,7 @@ class Lfs3:
|
||||
yield from self.sattrs()
|
||||
|
||||
# lookup data in the underlying bshrub
|
||||
def _lookupleaf(self, pos, *,
|
||||
def _lookupnext_(self, pos, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
# no bshrub?
|
||||
@@ -3557,7 +3557,7 @@ class Lfs3:
|
||||
return None, None
|
||||
|
||||
# lookup data in our bshrub
|
||||
r = self.bshrub.lookupleaf(pos,
|
||||
r = self.bshrub.lookupnext_(pos,
|
||||
path=path or depth,
|
||||
depth=depth)
|
||||
if path or depth:
|
||||
@@ -3606,11 +3606,11 @@ class Lfs3:
|
||||
else:
|
||||
return bid-(rattr.weight-1), rattr
|
||||
|
||||
def lookupleaf(self, pos, *,
|
||||
def lookupnext_(self, pos, *,
|
||||
data_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
r = self._lookupleaf(pos,
|
||||
r = self._lookupnext_(pos,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3634,7 +3634,7 @@ class Lfs3:
|
||||
depth=None):
|
||||
pos = 0
|
||||
while True:
|
||||
r = self.lookupleaf(pos,
|
||||
r = self.lookupnext_(pos,
|
||||
data_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
|
||||
+30
-30
@@ -1201,7 +1201,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1260,7 +1260,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1280,11 +1280,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1325,7 +1325,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1420,7 +1420,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1443,7 +1443,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1491,7 +1491,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1905,7 +1905,7 @@ class Mtree:
|
||||
return cls(bd, mrootchain, mtree,
|
||||
mbits=mbits)
|
||||
|
||||
def _lookupleaf(self, mid, *,
|
||||
def _lookupnext_(self, mid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not isinstance(mid, Mid):
|
||||
@@ -1940,8 +1940,8 @@ class Mtree:
|
||||
|
||||
# mtree? lookup in mtree
|
||||
else:
|
||||
# need to do two steps here in case lookupleaf stops early
|
||||
r = self.mtree.lookupleaf(mid.mid,
|
||||
# need to do two steps here in case lookupnext_ stops early
|
||||
r = self.mtree.lookupnext_(mid.mid,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -1985,13 +1985,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def lookupleaf(self, mid, *,
|
||||
def lookupnext_(self, mid, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _lookupleaf, this just helps
|
||||
# most of the logic is in _lookupnext_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._lookupleaf(mid,
|
||||
r = self._lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2017,7 +2017,7 @@ class Mtree:
|
||||
mid = self.mid(mid)
|
||||
|
||||
# lookup the relevant mdir
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2077,7 +2077,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2255,7 +2255,7 @@ class Mtree:
|
||||
if not isinstance(mid, Mid):
|
||||
mid = self.mid(mid)
|
||||
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2281,7 +2281,7 @@ class Mtree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def _namelookupleaf(self, did, name, *,
|
||||
def _namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if path or depth:
|
||||
@@ -2307,8 +2307,8 @@ class Mtree:
|
||||
|
||||
# mtree? find name in mtree
|
||||
else:
|
||||
# need to do two steps here in case namelookupleaf stops early
|
||||
r = self.mtree.namelookupleaf(did, name,
|
||||
# need to do two steps here in case namelookup_ stops early
|
||||
r = self.mtree.namelookup_(did, name,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -2352,13 +2352,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _namelookupleaf, this just helps
|
||||
# most of the logic is in _namelookup_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._namelookupleaf(did, name,
|
||||
r = self._namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2381,7 +2381,7 @@ class Mtree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# lookup the relevant mdir
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3352,7 +3352,7 @@ class Lfs3:
|
||||
mbid, mrid = mid.mbid, mid.mrid + 1
|
||||
if mrid == mdir.weight:
|
||||
mbid, mrid = mbid + (1 << self.mbits), 0
|
||||
mdir = self.mtree.lookupleaf(mbid)
|
||||
mdir = self.mtree.lookupnext_(mbid)
|
||||
if mdir is None:
|
||||
break
|
||||
# lookup name and adjust rid if necessary, you don't
|
||||
@@ -3576,7 +3576,7 @@ class Lfs3:
|
||||
yield from self.sattrs()
|
||||
|
||||
# lookup data in the underlying bshrub
|
||||
def _lookupleaf(self, pos, *,
|
||||
def _lookupnext_(self, pos, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
# no bshrub?
|
||||
@@ -3587,7 +3587,7 @@ class Lfs3:
|
||||
return None, None
|
||||
|
||||
# lookup data in our bshrub
|
||||
r = self.bshrub.lookupleaf(pos,
|
||||
r = self.bshrub.lookupnext_(pos,
|
||||
path=path or depth,
|
||||
depth=depth)
|
||||
if path or depth:
|
||||
@@ -3636,11 +3636,11 @@ class Lfs3:
|
||||
else:
|
||||
return bid-(rattr.weight-1), rattr
|
||||
|
||||
def lookupleaf(self, pos, *,
|
||||
def lookupnext_(self, pos, *,
|
||||
data_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
r = self._lookupleaf(pos,
|
||||
r = self._lookupnext_(pos,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3664,7 +3664,7 @@ class Lfs3:
|
||||
depth=None):
|
||||
pos = 0
|
||||
while True:
|
||||
r = self.lookupleaf(pos,
|
||||
r = self.lookupnext_(pos,
|
||||
data_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
|
||||
+8
-8
@@ -1029,7 +1029,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1088,7 +1088,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1108,11 +1108,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1153,7 +1153,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1248,7 +1248,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1271,7 +1271,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1319,7 +1319,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
|
||||
+30
-30
@@ -1096,7 +1096,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1155,7 +1155,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1175,11 +1175,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1220,7 +1220,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1315,7 +1315,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1338,7 +1338,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1386,7 +1386,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1800,7 +1800,7 @@ class Mtree:
|
||||
return cls(bd, mrootchain, mtree,
|
||||
mbits=mbits)
|
||||
|
||||
def _lookupleaf(self, mid, *,
|
||||
def _lookupnext_(self, mid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not isinstance(mid, Mid):
|
||||
@@ -1835,8 +1835,8 @@ class Mtree:
|
||||
|
||||
# mtree? lookup in mtree
|
||||
else:
|
||||
# need to do two steps here in case lookupleaf stops early
|
||||
r = self.mtree.lookupleaf(mid.mid,
|
||||
# need to do two steps here in case lookupnext_ stops early
|
||||
r = self.mtree.lookupnext_(mid.mid,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -1880,13 +1880,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def lookupleaf(self, mid, *,
|
||||
def lookupnext_(self, mid, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _lookupleaf, this just helps
|
||||
# most of the logic is in _lookupnext_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._lookupleaf(mid,
|
||||
r = self._lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1912,7 +1912,7 @@ class Mtree:
|
||||
mid = self.mid(mid)
|
||||
|
||||
# lookup the relevant mdir
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1972,7 +1972,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2150,7 +2150,7 @@ class Mtree:
|
||||
if not isinstance(mid, Mid):
|
||||
mid = self.mid(mid)
|
||||
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2176,7 +2176,7 @@ class Mtree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def _namelookupleaf(self, did, name, *,
|
||||
def _namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if path or depth:
|
||||
@@ -2202,8 +2202,8 @@ class Mtree:
|
||||
|
||||
# mtree? find name in mtree
|
||||
else:
|
||||
# need to do two steps here in case namelookupleaf stops early
|
||||
r = self.mtree.namelookupleaf(did, name,
|
||||
# need to do two steps here in case namelookup_ stops early
|
||||
r = self.mtree.namelookup_(did, name,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -2247,13 +2247,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _namelookupleaf, this just helps
|
||||
# most of the logic is in _namelookup_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._namelookupleaf(did, name,
|
||||
r = self._namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2276,7 +2276,7 @@ class Mtree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# lookup the relevant mdir
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3247,7 +3247,7 @@ class Lfs3:
|
||||
mbid, mrid = mid.mbid, mid.mrid + 1
|
||||
if mrid == mdir.weight:
|
||||
mbid, mrid = mbid + (1 << self.mbits), 0
|
||||
mdir = self.mtree.lookupleaf(mbid)
|
||||
mdir = self.mtree.lookupnext_(mbid)
|
||||
if mdir is None:
|
||||
break
|
||||
# lookup name and adjust rid if necessary, you don't
|
||||
@@ -3471,7 +3471,7 @@ class Lfs3:
|
||||
yield from self.sattrs()
|
||||
|
||||
# lookup data in the underlying bshrub
|
||||
def _lookupleaf(self, pos, *,
|
||||
def _lookupnext_(self, pos, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
# no bshrub?
|
||||
@@ -3482,7 +3482,7 @@ class Lfs3:
|
||||
return None, None
|
||||
|
||||
# lookup data in our bshrub
|
||||
r = self.bshrub.lookupleaf(pos,
|
||||
r = self.bshrub.lookupnext_(pos,
|
||||
path=path or depth,
|
||||
depth=depth)
|
||||
if path or depth:
|
||||
@@ -3531,11 +3531,11 @@ class Lfs3:
|
||||
else:
|
||||
return bid-(rattr.weight-1), rattr
|
||||
|
||||
def lookupleaf(self, pos, *,
|
||||
def lookupnext_(self, pos, *,
|
||||
data_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
r = self._lookupleaf(pos,
|
||||
r = self._lookupnext_(pos,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -3559,7 +3559,7 @@ class Lfs3:
|
||||
depth=None):
|
||||
pos = 0
|
||||
while True:
|
||||
r = self.lookupleaf(pos,
|
||||
r = self.lookupnext_(pos,
|
||||
data_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
|
||||
+24
-24
@@ -1044,7 +1044,7 @@ class Btree:
|
||||
shrub = Rbyd.fetchshrub(rbyd, trunk)
|
||||
return cls(bd, shrub)
|
||||
|
||||
def lookupleaf(self, bid, *,
|
||||
def lookupnext_(self, bid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not self or bid >= self.weight:
|
||||
@@ -1103,7 +1103,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1123,11 +1123,11 @@ class Btree:
|
||||
#
|
||||
# note this function expects bid to be known, use lookupnext
|
||||
# first if you don't care about the exact bid (or better yet,
|
||||
# lookupleaf and call lookup on the returned rbyd)
|
||||
# lookupnext_ and call lookup on the returned rbyd)
|
||||
#
|
||||
# this matches rbyd's lookup behavior, which needs a known rid
|
||||
# to avoid a double lookup
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1168,7 +1168,7 @@ class Btree:
|
||||
|
||||
bid = 0
|
||||
while True:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if r:
|
||||
@@ -1263,7 +1263,7 @@ class Btree:
|
||||
else:
|
||||
yield bid_, rattr
|
||||
else:
|
||||
r = self.lookupleaf(bid,
|
||||
r = self.lookupnext_(bid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1286,7 +1286,7 @@ class Btree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
rbyd = self.rbyd
|
||||
@@ -1334,7 +1334,7 @@ class Btree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# just discard the rbyd info
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1748,7 +1748,7 @@ class Mtree:
|
||||
return cls(bd, mrootchain, mtree,
|
||||
mbits=mbits)
|
||||
|
||||
def _lookupleaf(self, mid, *,
|
||||
def _lookupnext_(self, mid, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if not isinstance(mid, Mid):
|
||||
@@ -1783,8 +1783,8 @@ class Mtree:
|
||||
|
||||
# mtree? lookup in mtree
|
||||
else:
|
||||
# need to do two steps here in case lookupleaf stops early
|
||||
r = self.mtree.lookupleaf(mid.mid,
|
||||
# need to do two steps here in case lookupnext_ stops early
|
||||
r = self.mtree.lookupnext_(mid.mid,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -1828,13 +1828,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def lookupleaf(self, mid, *,
|
||||
def lookupnext_(self, mid, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _lookupleaf, this just helps
|
||||
# most of the logic is in _lookupnext_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._lookupleaf(mid,
|
||||
r = self._lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1860,7 +1860,7 @@ class Mtree:
|
||||
mid = self.mid(mid)
|
||||
|
||||
# lookup the relevant mdir
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -1920,7 +1920,7 @@ class Mtree:
|
||||
|
||||
mid = self.mid(0)
|
||||
while True:
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
mdirs_only=False,
|
||||
path=path,
|
||||
depth=depth)
|
||||
@@ -2098,7 +2098,7 @@ class Mtree:
|
||||
if not isinstance(mid, Mid):
|
||||
mid = self.mid(mid)
|
||||
|
||||
r = self.lookupleaf(mid,
|
||||
r = self.lookupnext_(mid,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2124,7 +2124,7 @@ class Mtree:
|
||||
yield rattr
|
||||
|
||||
# lookup by name
|
||||
def _namelookupleaf(self, did, name, *,
|
||||
def _namelookup_(self, did, name, *,
|
||||
path=False,
|
||||
depth=None):
|
||||
if path or depth:
|
||||
@@ -2150,8 +2150,8 @@ class Mtree:
|
||||
|
||||
# mtree? find name in mtree
|
||||
else:
|
||||
# need to do two steps here in case namelookupleaf stops early
|
||||
r = self.mtree.namelookupleaf(did, name,
|
||||
# need to do two steps here in case namelookup_ stops early
|
||||
r = self.mtree.namelookup_(did, name,
|
||||
path=path or depth,
|
||||
depth=depth-len(path_) if depth else None)
|
||||
if path or depth:
|
||||
@@ -2195,13 +2195,13 @@ class Mtree:
|
||||
else:
|
||||
return mdir
|
||||
|
||||
def namelookupleaf(self, did, name, *,
|
||||
def namelookup_(self, did, name, *,
|
||||
mdirs_only=True,
|
||||
path=False,
|
||||
depth=None):
|
||||
# most of the logic is in _namelookupleaf, this just helps
|
||||
# most of the logic is in _namelookup_, this just helps
|
||||
# deduplicate the mdirs_only logic
|
||||
r = self._namelookupleaf(did, name,
|
||||
r = self._namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
@@ -2224,7 +2224,7 @@ class Mtree:
|
||||
path=False,
|
||||
depth=None):
|
||||
# lookup the relevant mdir
|
||||
r = self.namelookupleaf(did, name,
|
||||
r = self.namelookup_(did, name,
|
||||
path=path,
|
||||
depth=depth)
|
||||
if path:
|
||||
|
||||
Reference in New Issue
Block a user