1
0
Fork 0
forked from github/pelican

turn utils.open into actual context manager so as to better handle encoding warnings

This commit is contained in:
dave mankoff 2012-06-10 18:26:53 -04:00
commit 876c7f5093

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import contextlib
import os
import re
import pytz
@ -32,10 +33,10 @@ def get_date(string):
pass
raise ValueError("'%s' is not a valid date" % string)
@contextlib.contextmanager
def open(filename):
"""Open a file and return it's content"""
return _open(filename, encoding='utf-8').read()
yield _open(filename, encoding='utf-8').read()
def slugify(value):