mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-20 17:52:50 +00:00
Remove a2b_l and b2a_l from public API, to ease likely future switch to stdlib
base64's implementation.
This commit is contained in:
parent
e23dbcdf56
commit
77ae087c77
@ -222,7 +222,7 @@ class ValidatedReadBucketProxy(log.PrefixingLogMixin):
|
||||
UEB"""
|
||||
precondition(share_hash_tree[0] is not None, share_hash_tree)
|
||||
prefix = "%d-%s-%s" % (sharenum, bucket,
|
||||
base32.b2a_l(share_hash_tree[0][:8], 60))
|
||||
base32.b2a(share_hash_tree[0][:8])[:12])
|
||||
log.PrefixingLogMixin.__init__(self,
|
||||
facility="tahoe.immutable.download",
|
||||
prefix=prefix)
|
||||
@ -465,7 +465,7 @@ class Checker(log.PrefixingLogMixin):
|
||||
monitor):
|
||||
assert precondition(isinstance(verifycap, CHKFileVerifierURI), verifycap, type(verifycap))
|
||||
|
||||
prefix = "%s" % base32.b2a_l(verifycap.get_storage_index()[:8], 60)
|
||||
prefix = "%s" % base32.b2a(verifycap.get_storage_index()[:8])[:12]
|
||||
log.PrefixingLogMixin.__init__(self, facility="tahoe.immutable.checker", prefix=prefix)
|
||||
|
||||
self._verifycap = verifycap
|
||||
|
@ -43,7 +43,7 @@ class ShareFinder(object):
|
||||
self.overdue_timers = {}
|
||||
|
||||
self._storage_index = verifycap.storage_index
|
||||
self._si_prefix = base32.b2a_l(self._storage_index[:8], 60)
|
||||
self._si_prefix = base32.b2a(self._storage_index[:8])[:12]
|
||||
self._node_logparent = logparent
|
||||
self._download_status = download_status
|
||||
self._lp = log.msg(format="ShareFinder[si=%(si)s] starting",
|
||||
|
@ -44,7 +44,7 @@ class DownloadNode(object):
|
||||
assert isinstance(verifycap, uri.CHKFileVerifierURI)
|
||||
self._verifycap = verifycap
|
||||
self._storage_broker = storage_broker
|
||||
self._si_prefix = base32.b2a_l(verifycap.storage_index[:8], 60)
|
||||
self._si_prefix = base32.b2a(verifycap.storage_index[:8])[:12]
|
||||
self.running = True
|
||||
if terminator:
|
||||
terminator.register(self) # calls self.stop() at stopService()
|
||||
|
@ -298,7 +298,7 @@ class BucketReader(Referenceable):
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s %s %s>" % (self.__class__.__name__,
|
||||
base32.b2a_l(self.storage_index[:8], 60),
|
||||
base32.b2a(self.storage_index[:8])[:12],
|
||||
self.shnum)
|
||||
|
||||
def remote_read(self, offset, length):
|
||||
|
@ -52,13 +52,13 @@ def b2a(os):
|
||||
|
||||
@return the contents of os in base-32 encoded form
|
||||
"""
|
||||
return b2a_l(os, len(os)*8)
|
||||
return _b2a_l(os, len(os)*8)
|
||||
|
||||
def b2a_or_none(os):
|
||||
if os is not None:
|
||||
return b2a(os)
|
||||
|
||||
def b2a_l(os, lengthinbits):
|
||||
def _b2a_l(os, lengthinbits):
|
||||
"""
|
||||
@param os the data to be encoded (a string)
|
||||
@param lengthinbits the number of bits of data in os to be encoded
|
||||
@ -204,9 +204,9 @@ def a2b(cs):
|
||||
precondition(could_be_base32_encoded(cs), "cs is required to be possibly base32 encoded data.", cs=cs)
|
||||
precondition(isinstance(cs, six.binary_type), cs)
|
||||
|
||||
return a2b_l(cs, num_octets_that_encode_to_this_many_quintets(len(cs))*8)
|
||||
return _a2b_l(cs, num_octets_that_encode_to_this_many_quintets(len(cs))*8)
|
||||
|
||||
def a2b_l(cs, lengthinbits):
|
||||
def _a2b_l(cs, lengthinbits):
|
||||
"""
|
||||
@param lengthinbits the number of bits of data in encoded into cs
|
||||
|
||||
@ -261,8 +261,8 @@ def a2b_l(cs, lengthinbits):
|
||||
pos = pos * 256
|
||||
assert len(octets) == numoctets, "len(octets): %s, numoctets: %s, octets: %s" % (len(octets), numoctets, octets,)
|
||||
res = ''.join(map(chr, octets))
|
||||
precondition(b2a_l(res, lengthinbits) == cs, "cs is required to be the canonical base-32 encoding of some data.", b2a(res), res=res, cs=cs)
|
||||
precondition(_b2a_l(res, lengthinbits) == cs, "cs is required to be the canonical base-32 encoding of some data.", b2a(res), res=res, cs=cs)
|
||||
return res
|
||||
|
||||
|
||||
__all__ = ["b2a", "b2a_l", "a2b", "a2b_l", "b2a_or_none", "BASE32CHAR_3bits", "BASE32CHAR_1bits", "BASE32CHAR", "BASE32STR_anybytes", "could_be_base32_encoded"]
|
||||
__all__ = ["b2a", "a2b", "b2a_or_none", "BASE32CHAR_3bits", "BASE32CHAR_1bits", "BASE32CHAR", "BASE32STR_anybytes", "could_be_base32_encoded"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user