def headers(self):
try:
headers = next(yaml.load_all(self.read(body=False)))
except StopIteration as e:
raise ValueError("YAML header is missing. Please ensure that the top of your post has a header of the following form:\n" + SAMPLE_HEADER)
except yaml.YAMLError as e:
raise ValueError(
"YAML header is incorrectly formatted or missing. The following information may be useful:\n{}\nIf you continue to have difficulties, try pasting your YAML header into an online parser such as http://yaml-online-parser.appspot.com/.".format(str(e)))
for key, value in headers.copy().items():
if isinstance(value, datetime.date):
headers[key] = datetime.datetime.combine(value, datetime.time(0))
if key == 'tags' and isinstance(value, list):
headers[key] = [str(v) if six.PY3 else unicode(v) for v in value]
return headers
评论列表
文章目录