[nodes/io] adds support for encoding kwarg to all file readers/writers (tests needed!).
This commit is contained in:
@ -18,6 +18,7 @@ class FileHandler(Configurable):
|
|||||||
path = Option(str, required=True, positional=True) # type: str
|
path = Option(str, required=True, positional=True) # type: str
|
||||||
eol = Option(str, default='\n') # type: str
|
eol = Option(str, default='\n') # type: str
|
||||||
mode = Option(str) # type: str
|
mode = Option(str) # type: str
|
||||||
|
encoding = Option(str, default='utf-8') # type: str
|
||||||
|
|
||||||
fs = Service('fs') # type: str
|
fs = Service('fs') # type: str
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class FileHandler(Configurable):
|
|||||||
yield file
|
yield file
|
||||||
|
|
||||||
def open(self, fs):
|
def open(self, fs):
|
||||||
return fs.open(self.path, self.mode)
|
return fs.open(self.path, self.mode, encoding=self.encoding)
|
||||||
|
|
||||||
|
|
||||||
class Reader(FileHandler):
|
class Reader(FileHandler):
|
||||||
|
|||||||
Reference in New Issue
Block a user