| 108 | | |
| 109 | | class DecodingFile(file): |
| 110 | | """ |
| 111 | | Wrapper class to open a file and read it as a specific encoding. This |
| 112 | | is a horrible hack and should be deprecated when deb822 is fixed. |
| 113 | | See Debian bug #495272 for more details. |
| 114 | | """ |
| 115 | | def __init__(self, name, mode='r', buffering=1, encoding='utf8'): |
| 116 | | file.__init__(self, name, mode, buffering) |
| 117 | | self._encoding = encoding |
| 118 | | |
| 119 | | def read(self, n=-1): |
| 120 | | data = file.read(self, n) |
| 121 | | return data.decode(self._encoding) |
| 122 | | |
| 123 | | def readline(self): |
| 124 | | data = file.readline(self) |
| 125 | | return data.decode(self._encoding) |