mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
re-import cgi. properly turn utils.open into a context manager
This commit is contained in:
parent
c608d39aa4
commit
caa4442abb
2 changed files with 9 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue