[py-svn] r10441 - in py/branch/py-collect: bin documentation misc
hpk at codespeak.net
hpk at codespeak.net
Fri Apr 8 18:37:09 CEST 2005
Author: hpk
Date: Fri Apr 8 18:37:09 2005
New Revision: 10441
Added:
py/branch/py-collect/misc/rest.py
Modified:
py/branch/py-collect/bin/py.rest
py/branch/py-collect/documentation/rest_test.py
Log:
move some rest functionality around at implementation
level
Modified: py/branch/py-collect/bin/py.rest
==============================================================================
--- py/branch/py-collect/bin/py.rest (original)
+++ py/branch/py-collect/bin/py.rest Fri Apr 8 18:37:09 2005
@@ -10,53 +10,9 @@
"""
+import os, sys
from _findpy import py
-
-import sys, os, traceback
-
-if hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno()):
- def log(msg):
- print msg
-else:
- def log(msg):
- pass
-
-def convert_rest_html(source, source_path, stylesheet=None):
- """ return html latin1-encoded document for the given input.
- source a ReST-string
- sourcepath where to look for includes (basically)
- stylesheet path (to be used if any)
- """
- from docutils.core import publish_string
- kwargs = {
- 'stylesheet' : stylesheet,
- 'traceback' : 1,
- 'output_encoding' : 'latin1',
- #'halt' : 0, # 'info',
- 'halt_level' : 2,
- }
- return publish_string(source, str(source_path), writer_name='html',
- settings_overrides=kwargs)
-
-def process(txtpath):
- """ process a textfile """
- log("processing %s" % txtpath)
- assert txtpath.check(ext='.txt')
- htmlpath = txtpath.localpath.new(ext='.html')
- #svninfopath = txtpath.localpath.new(ext='.svninfo')
-
- style = txtpath.dirpath('style.css')
- if style.check():
- stylesheet = style.basename
- else:
- stylesheet = None
- doc = convert_rest_html(txtpath.read(), txtpath,
- stylesheet=stylesheet)
- htmlpath.write(doc)
- #log("wrote %r" % htmlpath)
- #if txtpath.check(svnwc=1, versioned=1):
- # info = txtpath.info()
- # svninfopath.dumpobj(info)
+from py.__impl__.misc import rest
if __name__=='__main__':
basedir = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
@@ -74,6 +30,6 @@
if p.check(dir=1):
for x in p.visit(fil=py.path.checker(fnmatch='*.txt', versioned=True),
rec=py.path.checker(dotfile=0)):
- process(x)
+ rest.process(x)
elif p.check(file=1):
- process(p)
+ rest.process(p)
Modified: py/branch/py-collect/documentation/rest_test.py
==============================================================================
--- py/branch/py-collect/documentation/rest_test.py (original)
+++ py/branch/py-collect/documentation/rest_test.py Fri Apr 8 18:37:09 2005
@@ -1,9 +1,9 @@
from __future__ import generators
import py
+from py.__impl__.misc import rest
pydir = py.magic.autopath(vars(py)).dirpath()
-rest = pydir.join('bin', 'py.rest').pyimport('py_rest')
docdir = py.path.svnwc(pydir.join('documentation'))
def restcheck(path):
Added: py/branch/py-collect/misc/rest.py
==============================================================================
--- (empty file)
+++ py/branch/py-collect/misc/rest.py Fri Apr 8 18:37:09 2005
@@ -0,0 +1,47 @@
+
+import sys, os, traceback
+
+if hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno()):
+ def log(msg):
+ print msg
+else:
+ def log(msg):
+ pass
+
+def convert_rest_html(source, source_path, stylesheet=None):
+ """ return html latin1-encoded document for the given input.
+ source a ReST-string
+ sourcepath where to look for includes (basically)
+ stylesheet path (to be used if any)
+ """
+ from docutils.core import publish_string
+ kwargs = {
+ 'stylesheet' : stylesheet,
+ 'traceback' : 1,
+ 'output_encoding' : 'latin1',
+ #'halt' : 0, # 'info',
+ 'halt_level' : 2,
+ }
+ return publish_string(source, str(source_path), writer_name='html',
+ settings_overrides=kwargs)
+
+def process(txtpath):
+ """ process a textfile """
+ log("processing %s" % txtpath)
+ assert txtpath.check(ext='.txt')
+ htmlpath = txtpath.localpath.new(ext='.html')
+ #svninfopath = txtpath.localpath.new(ext='.svninfo')
+
+ style = txtpath.dirpath('style.css')
+ if style.check():
+ stylesheet = style.basename
+ else:
+ stylesheet = None
+ doc = convert_rest_html(txtpath.read(), txtpath,
+ stylesheet=stylesheet)
+ htmlpath.write(doc)
+ #log("wrote %r" % htmlpath)
+ #if txtpath.check(svnwc=1, versioned=1):
+ # info = txtpath.info()
+ # svninfopath.dumpobj(info)
+
More information about the pytest-commit
mailing list