re-import cgi. properly turn utils.open into a context manager

This commit is contained in:
dave mankoff 2012-06-20 19:59:32 -04:00
commit caa4442abb
2 changed files with 9 additions and 3 deletions

View file

@ -15,7 +15,8 @@ except ImportError:
Markdown = False # NOQA Markdown = False # NOQA
import re import re
from htmlparser import HTMLParser import cgi
from HTMLParser import HTMLParser
from pelican.contents import Category, Tag, Author from pelican.contents import Category, Tag, Author
from pelican.utils import get_date, open from pelican.utils import get_date, open

View file

@ -34,10 +34,15 @@ def get_date(string):
raise ValueError("'%s' is not a valid date" % string) raise ValueError("'%s' is not a valid date" % string)
def open(filename): class open(object):
"""Open a file and return it's content""" """Open a file and return it's content"""
return _open(filename, encoding='utf-8').read() def __init__(self, filename):
self.filename = filename
def __enter__(self):
return _open(self.filename, encoding='utf-8').read()
def __exit__(self, exc_type, exc_value, traceback):
pass
def slugify(value): def slugify(value):
""" """