Commit 571b9a3e by rfkelly0

LazyFS: custom __unicode__() and __str__()

parent b182e75e
......@@ -9,6 +9,8 @@ initialise its underlying FS object.
"""
import sys
try:
from threading import Lock
except ImportError:
......@@ -30,6 +32,17 @@ class LazyFS(WrapFS):
super(LazyFS,self).__init__(fs)
self._lazy_creation_lock = Lock()
def __unicode__(self):
try:
wrapped_fs = self.__dict__["wrapped_fs"]
except KeyError:
return u"<LazyFS wrapping %s>" % (self._fsclass,)
else:
return u"<LazyFS wrapping %s>" % (wrapped_fs,)
def __str__(self):
return unicode(self).encode(sys.getdefaultencoding(),"replace")
def __getstate__(self):
state = super(LazyFS,self).__getstate__()
del state["_lazy_creation_lock"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment