[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/metacode pegboard.py
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz/metacode pegboard.py |
Date: |
Thu, 31 Oct 2002 04:12:57 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/10/31 04:12:57
Modified files:
metacode : pegboard.py
Log message:
Scans through all PEG-dirs, skips invalid rst-files.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/metacode/pegboard.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: gzz/metacode/pegboard.py
diff -u gzz/metacode/pegboard.py:1.3 gzz/metacode/pegboard.py:1.4
--- gzz/metacode/pegboard.py:1.3 Mon Oct 28 03:37:27 2002
+++ gzz/metacode/pegboard.py Thu Oct 31 04:12:57 2002
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, Benja Fallenstein
+# Copyright (c) 2002, Benja Fallenstein, Asko Soukka
#
# You may use and distribute under the terms of either the GNU Lesser
# General Public License, either version 2 of the license or,
@@ -15,9 +15,9 @@
# file for more details.
#
-
# Creating the pegboard
-# Must be run in the main directory (the one Makefile is in).
+# Must be run in the main directory (the one Makefile is in),
+# because of hardcoded pegroot and css.
import docutils
import docutils.core
@@ -27,43 +27,58 @@
def __init__(self, **attrs):
for (k,v) in attrs.items(): setattr(self, k, v)
-def is_number(string):
- for char in string:
- if not char in "0123456789": return 0
- else:
- return 1
+pegroot = 'doc/pegboard'
+css = '../gzz.css'
-pegdirs = [d for d in os.listdir('doc/pegboard/')
- if os.path.isdir('doc/pegboard/'+d) and is_number(d)]
-
-pegs = [os.path.split(dir)[-1] for dir in pegdirs]
-
-for peg in pegs:
- f = 'doc/pegboard/%s/PEG_%s' % (peg, peg)
- if not os.path.exists(f+'.rst'): continue
-
- print "Process PEG %s" % (peg,)
-
- args = '-stg --stylesheet doc/gzz.css %s.rst %s.html' % (f,f)
+pegdirs = [d for d in os.listdir(pegroot+'/') if os.path.isdir(pegroot+'/'+d)]
- # Generate the HTML
- docutils.core.publish(writer_name='html', argv=args.split())
+#loop one: converting pegs
+for pegdir in pegdirs:
+ rstfiles = [f for f in os.listdir(pegroot+'/'+pegdir+'/')
+ if os.path.isfile(pegroot+'/'+pegdir+'/'+f) and
f.endswith('.rst')]
+
+ print "Process PEG %s" % (pegdir)
+ for rstfile in rstfiles:
+ file = pegroot+'/'+pegdir+'/'+rstfile.rstrip('.rst')
+
+ # Sets docutils' "command line arguments"
+ args = '-stg --stylesheet ../'+css+' %s.rst %s.html' % (file,file)
+
+ # Generate the HTML
+ try:
+ docutils.core.publish(writer_name='html', argv=args.split())
+ except:
+ print "XXX"
+ print "PEG %s: Docutil raised an exception while converting %s." %
(pegdir, f)
+ print "Conversion failed and HTML not created."
- if 0:
+# if 0:
#config = docutils.frontend.ConfigParser()
#defaults = config.get_section('options')
- opts = docutils.frontend.OptionParser()
+# opts = docutils.frontend.OptionParser()
#opts.set_defaults(**defaults)
- opts.input_encoding = "utf-8"
- opts.report_level = "0"
- opts.halt_level = "3"
- opts.warning_stream = sys.stdout
- opts.debug = "0"
- opts.language_code = "en"
+# opts.input_encoding = "utf-8"
+# opts.report_level = "0"
+# opts.halt_level = "3"
+# opts.warning_stream = sys.stdout
+# opts.debug = "0"
+# opts.language_code = "en"
- ioobj = docutils.io.FileIO(opts, source_path="%s.rst" % (f,))
- reader = docutils.readers.get_reader_class("rst")(None, None)
+# ioobj = docutils.io.FileIO(opts, source_path="%s.rst" % (f,))
+# reader = docutils.readers.get_reader_class("rst")(None, None)
# doc = reader.read(ioobj, "restructuredtext", opts)
- reader.set_parser("restructuredtext")
- doc = reader.read(ioobj, None, opts)
- print doc
+# reader.set_parser("restructuredtext")
+# doc = reader.read(ioobj, None, opts)
+# print doc
+
+
+
+
+
+
+
+
+
+
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/metacode pegboard.py,
Asko Soukka <=