Encoder.__repr__: mention the file being encoded

This commit is contained in:
Brian Warner 2007-08-09 18:26:56 -07:00
parent 684966d103
commit 08ee80176a

View File

@ -6,7 +6,7 @@ from twisted.python import log
from foolscap import eventual
from allmydata import uri
from allmydata.hashtree import HashTree
from allmydata.util import mathutil, hashutil
from allmydata.util import mathutil, hashutil, idlib
from allmydata.util.assertutil import _assert
from allmydata.codec import CRSEncoder
from allmydata.interfaces import IEncoder, IStorageBucketWriter, \
@ -90,6 +90,11 @@ class Encoder(object):
self.uri_extension_data = {}
self._codec = None
def __repr__(self):
if hasattr(self, "_storage_index"):
return "<Encoder for %s>" % idlib.b2a(self._storage_index)[:6]
return "<Encoder for unknown storage index>"
def set_size(self, size):
assert not self._codec
self.file_size = size