diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-01-24 12:36:16 -0800 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-01-24 12:36:16 -0800 |
commit | 008198b5491d9c394968a8c7c3f524ddee9f59bc (patch) | |
tree | 2e021009da4f5bec5e8b0046b129d7306660823e /pystache | |
parent | 78ef793b779b8a22f3e662267a4d72ac99d7f8dd (diff) | |
download | pystache-008198b5491d9c394968a8c7c3f524ddee9f59bc.tar.gz |
Added optional encoding argument to Reader.read().
Diffstat (limited to 'pystache')
-rw-r--r-- | pystache/reader.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pystache/reader.py b/pystache/reader.py index 4a2ec10..7477794 100644 --- a/pystache/reader.py +++ b/pystache/reader.py @@ -42,14 +42,17 @@ class Reader(object): self.decode_errors = decode_errors self.encoding = encoding - def read(self, path): + def read(self, path, encoding=None): """ Read the template at the given path, and return it as a unicode string. """ + if encoding is None: + encoding = self.encoding + with open(path, 'r') as f: text = f.read() - text = unicode(text, self.encoding, self.decode_errors) + text = unicode(text, encoding, self.decode_errors) return text |