[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] navidoc ./rst2any.py navidoc/__init__.py navido...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] navidoc ./rst2any.py navidoc/__init__.py navido... |
Date: |
Mon, 24 Mar 2003 03:08:14 -0500 |
CVSROOT: /cvsroot/navidoc
Module name: navidoc
Changes by: Asko Soukka <address@hidden> 03/03/24 03:08:13
Modified files:
. : rst2any.py
navidoc : __init__.py
navidoc/directives: pegboard.py
navidoc/utils : path.py
Log message:
pegboard fix
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/rst2any.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/__init__.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/pegboard.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/utils/path.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: navidoc/navidoc/__init__.py
diff -u navidoc/navidoc/__init__.py:1.5 navidoc/navidoc/__init__.py:1.6
--- navidoc/navidoc/__init__.py:1.5 Fri Mar 21 09:35:53 2003
+++ navidoc/navidoc/__init__.py Mon Mar 24 03:08:13 2003
@@ -19,7 +19,7 @@
# MA 02111-1307 USA
#
-#$Id: __init__.py,v 1.5 2003/03/21 14:35:53 humppake Exp $
+#$Id: __init__.py,v 1.6 2003/03/24 08:08:13 humppake Exp $
#
# Written by Asko Soukka
@@ -31,8 +31,11 @@
import config
import navidoc.directives
-#import navidoc.utils.path
-#docutils.utils.relative_path = navidoc.utils.path.relative_path
+
+# Because docutils' own relative path has problems with
+# paths beginning with '../', we use our own :-)
+import navidoc.utils.path
+docutils.utils.relative_path = navidoc.utils.path.relative_path
def docutils_system_message(self, level, message, *children, **kwargs):
"""
Index: navidoc/navidoc/directives/pegboard.py
diff -u navidoc/navidoc/directives/pegboard.py:1.7
navidoc/navidoc/directives/pegboard.py:1.8
--- navidoc/navidoc/directives/pegboard.py:1.7 Fri Mar 21 09:39:37 2003
+++ navidoc/navidoc/directives/pegboard.py Mon Mar 24 03:08:13 2003
@@ -25,7 +25,6 @@
__docformat__ = 'reStructuredText'
-
import os, string
from docutils import Component
@@ -121,16 +120,15 @@
peg = {'authors': [], 'status': config.pegboard_undefined, 'topic':
pegdir,
'stakeholders': [], 'last-modified': '', 'dir': pegdir,
'files': '',
- 'html': '', 'rst': '', 'rstfiles': [], 'cvsignore': [] }
+ 'html': '', 'rst': '', 'rstfiles': [], 'ignore': [] }
peg['files'] = [f for f in os.listdir(config.working_directory) \
if
os.path.isfile(_slashify(config.working_directory)+f)
and not f.startswith('.') and '#' not in f and '~' not
in f]
- try:
- index = peg['files'].index('peg.rst')
- peg['rst'] = peg['files'][index]
- except ValueError:
+ if peg['files'].count('peg.rst') > 0:
+ peg['rst'] = 'peg.rst'
+ else:
for pegfile in peg['files']:
if pegfile.endswith('.rst'):
peg['rst'] = pegfile
@@ -141,15 +139,14 @@
pub = Publisher()
pub.set_reader('standalone', None, 'restructuredtext')
filename = _slashify(config.working_directory)+rstfile
- #" tmp" at the end of the next line is for jython to avoid
negative arraylength :)
- pub.process_command_line(argv=("--config "+config.docutils+"
"+filename+" tmp").split())
+ pub.process_command_line(argv=('--config '+config.docutils+'
'+filename+'').split())
#conversion may fail because of bad restructuredtext
try:
pub.set_io()
document = pub.reader.read(pub.source, pub.parser,
pub.settings)
pub.apply_transforms(document)
- peg['cvsignore'].append(rstfile[0:len(rstfile)-4]+'.gen.html')
+ peg['ignore'].append(rstfile[0:len(rstfile)-4]+'.gen.html')
#conversion have succeeded so far, parsing peg's metadata
#from its document tree
@@ -176,19 +173,19 @@
dbg_fail('PEG %s: Docutil raised an exception while converting
%s. ' % (pegdir, rstfile))
dbg_fail('Conversion failed and HTML not created.\n')
- if not peg['html']:
- for file in peg['files']:
- if file[len(file)-5:len(file)] == '.html':
- peg['html'] = file
- break
- elif file[len(file)-4:len(file)] in ('.rst', '.txt'):
- peg['html'] = file
- break
+ if not peg['html']:
+ for file in peg['files']:
+ if file[len(file)-5:len(file)] == '.html':
+ peg['html'] = file
+ break
+ elif file[len(file)-4:len(file)] in ('.rst', '.txt'):
+ peg['html'] = file
+ break
- config.working_directory = init_working_directory
+ #finally adds peg's metadata into pegtable
+ pegtable.append(peg)
- #finally adds peg's metadata into pegtable
- pegtable.append(peg)
+ config.working_directory = init_working_directory
return pegtable
#create the ``.. pegboard::`` directive
@@ -250,7 +247,7 @@
status_emph += status_comment
status = [
- nodes.Text(status_field[0] + " "),
+ nodes.Text(status_field[0] + ' '),
status_emph
]
@@ -304,7 +301,7 @@
def make_files(peg):
# again, cpython and 'class'
- # list = nodes.bullet_list(class="plain")
+ # list = nodes.bullet_list(class='pain')
list = nodes.bullet_list()
list['class'] = 'plain'
@@ -316,7 +313,7 @@
for file in peg['files']:
try:
- if peg['cvsignore'].index(file):
+ if peg['ignore'].index(file):
pass
except ValueError:
converted = 0
@@ -325,7 +322,7 @@
for rstfile in peg['rstfiles']:
if rstfile['filename'] == file:
status = rstfile['status']
- for htmlfile in peg['cvsignore']:
+ for htmlfile in peg['ignore']:
if htmlfile == file[0:len(file)-4]+'.html':
converted = htmlfile
if converted:
Index: navidoc/navidoc/utils/path.py
diff -u navidoc/navidoc/utils/path.py:1.4 navidoc/navidoc/utils/path.py:1.5
--- navidoc/navidoc/utils/path.py:1.4 Fri Mar 21 05:36:28 2003
+++ navidoc/navidoc/utils/path.py Mon Mar 24 03:08:13 2003
@@ -19,7 +19,7 @@
# MA 02111-1307 USA
#
-#$Id: path.py,v 1.4 2003/03/21 10:36:28 humppake Exp $
+#$Id: path.py,v 1.5 2003/03/24 08:08:13 humppake Exp $
#
# Written by Asko Soukka
@@ -35,10 +35,12 @@
extensions under path. Nonrecursive.
"""
files = [f for f in os.listdir(path) if not f.startswith('.')
- and not f == "CVS" and '#' not in f and '~' not in f]
+ and not f == 'CVS' and '#' not in f and '~' not in f]
+
+ files = [f for f in files if extensions.count(f.split('.')[-1]) > 0 \
+ or os.path.isdir(_slashify(path)+f)]
if not dirs:
- files = [f for f in os.listdir(path) if
os.path.isfile(_slashify(path)+f)]
- files = [f for f in files if extensions.count(f.split('.')[-1]) > 0]
+ files = [f for f in files if os.path.isfile(_slashify(path)+f)]
return files
def _slashify(path):
@@ -46,20 +48,21 @@
Add a trailing slash if not already there.
"""
if len(path) > 0:
- return (path+"/").replace("//","/")
+ return (path+'/').replace('//','/')
return path
def relative_path(source, target):
"""
Returns a relative path from the source to the target.
"""
- if source.startswith("../") or target.startswith("../"):
+ if source == None or len(source) == 0: return target
+ if source.startswith('../') or target.startswith('../'):
source = os.path.normpath(os.path.abspath(source))
target = os.path.normpath(os.path.abspath(target))
- depth = source.count("/")
- source_parts = source.split("/")
- target_parts = target.split("/")
+ depth = source.count('/')
+ source_parts = source.split('/')
+ target_parts = target.split('/')
parts = len(source_parts) < len(target_parts) \
and len(source_parts) or len(target_parts)
@@ -69,8 +72,8 @@
parts = i
break
- relative = "".join(["../" for i in range(depth-parts)]) \
- +"".join([target_parts[i+parts]+"/" \
+ relative = ''.join(['../' for i in range(depth-parts)]) \
+ +''.join([target_parts[i+parts]+'/' \
for i in range(len(target_parts)-parts)])
return (relative[0:len(relative)-1])
Index: navidoc/rst2any.py
diff -u navidoc/rst2any.py:1.11 navidoc/rst2any.py:1.12
--- navidoc/rst2any.py:1.11 Fri Mar 21 17:02:54 2003
+++ navidoc/rst2any.py Mon Mar 24 03:08:13 2003
@@ -75,31 +75,31 @@
if last_dot != -1: output = input[:last_dot]
else: output = input
- dbg_config("Working directory: "+config.working_directory)
- dbg_config("Input file: "+config.input_filename)
+ dbg_config('Working directory: '+config.working_directory)
+ dbg_config('Input file: '+config.input_filename)
if html:
dbg('Compiling: '+input)
if not output.endswith('index'):
- output = output+".gen.html"
+ output = output+'.gen.html'
else:
# For practical reasons, we need to transform
# index.rst into index.html ...
- output = output+".html"
+ output = output+'.html'
config.output_filename = os.path.basename(output)
- dbg_config("Output file: "+config.output_filename)
- args = "--config "+config.docutils+" "+input+' '+output
+ dbg_config('Output file: '+config.output_filename)
+ args = '--config '+config.docutils+' '+input+' '+output
docutils.core.publish_cmdline(writer_name='html', argv=args.split())
if latex:
dbg('Compiling: '+input)
- output = output+".gen.latex"
+ output = output+'.gen.latex'
config.output_filename = os.path.basename(output)
- dbg_config("Output file: "+config.output_filename)
- args = "--config "+config.docutils+" "+input+' '+output
+ dbg_config('Output file: '+config.output_filename)
+ args = '--config '+config.docutils+' '+input+' '+output
docutils.core.publish_cmdline(writer_name='latex', argv=args.split())
- config.output_filename = ""
+ config.output_filename = ''
def postprocess(path):
"""
@@ -120,7 +120,7 @@
specified by ``path``) and forwards them to conversion method.
"""
if os.path.isdir(path) and not os.path.islink(path):
- dirlist = _listdir(path,["rst"],dirs=1)
+ dirlist = _listdir(path,['rst'],dirs=1)
if os.path.isfile(_slashify(path) + 'docutils.conf'):
config.docutils = _slashify(path) + 'docutils.conf'
for entry in dirlist:
@@ -134,7 +134,7 @@
config.working_directory = os.path.normpath(os.path.dirname(path))
config.input_filename = os.path.basename(path+'.rst')
rst2any(path+'.rst')
- config.input_filename = ""
+ config.input_filename = ''
# catching loop parameters from the command line
try: sys.argv.remove('--loop'); loop = 1