1
0
Fork 0
forked from github/pelican

Change name of utils.open function to pelican_open and refactor this change across project.

This commit is contained in:
Wladislaw Merezhko 2012-09-08 13:07:51 +03:00
commit 0c2625e59d
2 changed files with 7 additions and 6 deletions

View file

@ -16,7 +16,7 @@ except ImportError:
import re
from pelican.contents import Category, Tag, Author
from pelican.utils import get_date, open
from pelican.utils import get_date, pelican_open
_METADATA_PROCESSORS = {
@ -129,7 +129,7 @@ class MarkdownReader(Reader):
def read(self, filename):
"""Parse content and metadata of markdown files"""
text = open(filename)
text = pelican_open(filename)
md = Markdown(extensions=set(self.extensions + ['meta']))
content = md.convert(text)
@ -146,7 +146,7 @@ class HtmlReader(Reader):
def read(self, filename):
"""Parse content and metadata of (x)HTML files"""
with open(filename) as content:
with pelican_open(filename) as content:
metadata = {'title': 'unnamed'}
for i in self._re.findall(content):
key = i.split(':')[0][5:].strip()

View file

@ -6,7 +6,7 @@ import shutil
import logging
from collections import defaultdict
from codecs import open as _open
from codecs import open
from datetime import datetime
from itertools import groupby
from jinja2 import Markup
@ -14,6 +14,7 @@ from operator import attrgetter
logger = logging.getLogger(__name__)
class NoFilesError(Exception):
pass
@ -37,9 +38,9 @@ def get_date(string):
raise ValueError("'%s' is not a valid date" % string)
def open(filename):
def pelican_open(filename):
"""Open a file and return it's content"""
return _open(filename, encoding='utf-8').read()
return open(filename, encoding='utf-8').read()
def slugify(value):