MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / SimpleTextIOWrapper

Class SimpleTextIOWrapper

pager_lib/tqdm/utils.py:163–180  ·  view source on GitHub ↗

Change only `.write()` of the wrapped object by encoding the passed value and passing the result to the wrapped object's `.write()` method.

Source from the content-addressed store, hash-verified

161
162
163class SimpleTextIOWrapper(ObjectWrapper):
164 """
165 Change only `.write()` of the wrapped object by encoding the passed
166 value and passing the result to the wrapped object's `.write()` method.
167 """
168 # pylint: disable=too-few-public-methods
169 def __init__(self, wrapped, encoding):
170 super().__init__(wrapped)
171 self.wrapper_setattr('encoding', encoding)
172
173 def write(self, s):
174 """
175 Encode `s` and pass to the wrapped object's `.write()` method.
176 """
177 return self._wrapped.write(s.encode(self.wrapper_getattr('encoding')))
178
179 def __eq__(self, other):
180 return self._wrapped == getattr(other, '_wrapped', other)
181
182
183class DisableOnWriteError(ObjectWrapper):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected