Permalink
Browse files

Add new rstDocument config system without PyYAML

  • Loading branch information...
1 parent 470046f commit ff906d41de81fc9be094b498a4888540f2b9a9a8 @jarus jarus committed Oct 8, 2011
Showing with 9 additions and 7 deletions.
  1. +9 −6 flaskrst/parsers.py
  2. +0 −1 setup.py
View
@@ -10,12 +10,14 @@
from __future__ import with_statement
import os
-import yaml
+import re
from flask import abort
from jinja2 import Markup
from docutils.core import publish_parts
+config_parser_re = re.compile(r"^:(\w+): ?(.*?)$", re.M)
+
class rstDocument(object):
def __init__(self, file_path):
self.file_path = file_path
@@ -25,20 +27,21 @@ def __init__(self, file_path):
if not os.path.isfile(self.file_path):
abort(404)
with open(self.file_path) as f:
- file_content = f.read()
- self._config, self._rst = file_content.split("\n\n", 1)
+ self.raw = f.read()
@property
def config(self):
if not isinstance(self._config, dict):
- self._config = yaml.load(self._config)
+ self._config = {}
+ for m in config_parser_re.finditer(self.raw):
+ self._config[m.group(1)] = eval(m.group(2))
self._config.setdefault('public', False)
- return self._config
+ return self._config
@property
def rst(self):
if not isinstance(self._rst, dict):
- self._rst = publish_parts(source=self._rst, \
+ self._rst = publish_parts(source=self.raw, \
writer_name='html4css1')
return self._rst
View
@@ -17,7 +17,6 @@
install_requires=[
'Flask>=0.7',
'Flask-Script',
- 'PyYAML',
'docutils',
'Flask-Testing'
],

0 comments on commit ff906d4

Please sign in to comment.