gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] navidoc ./config.py ./rst2any.py navidoc/__init...


From: Asko Soukka
Subject: [Gzz-commits] navidoc ./config.py ./rst2any.py navidoc/__init...
Date: Fri, 28 Mar 2003 08:08:58 -0500

CVSROOT:        /cvsroot/navidoc
Module name:    navidoc
Changes by:     Asko Soukka <address@hidden>    03/03/28 08:08:58

Modified files:
        .              : config.py rst2any.py 
        navidoc        : __init__.py parser.py 
        navidoc/directives: __init__.py latex.py mp.py pegboard.py 
        navidoc/link   : __init__.py 
        navidoc/modules: metalink.py navbar.py 
        navidoc/mp     : __init__.py uml.py 
        navidoc/utils  : path.py 

Log message:
        some unfinished stuff and enabling pegboard directive

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/config.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/rst2any.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/__init__.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/parser.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/__init__.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/latex.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/mp.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/directives/pegboard.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/link/__init__.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/modules/metalink.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/modules/navbar.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/mp/__init__.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/mp/uml.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/navidoc/navidoc/navidoc/utils/path.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: navidoc/config.py
diff -u navidoc/config.py:1.7 navidoc/config.py:1.8
--- navidoc/config.py:1.7       Thu Mar 27 06:56:21 2003
+++ navidoc/config.py   Fri Mar 28 08:08:57 2003
@@ -19,16 +19,13 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: config.py,v 1.7 2003/03/27 11:56:21 humppake Exp $
+# $Id: config.py,v 1.8 2003/03/28 13:08:57 humppake Exp $
 
 __docformat__ = 'reStructuredText'
 
 dbg = None
 
-import os.path
-import docutils.utils
-
-from navidoc.utils.debug import DebugFilter
+import navidoc.utils.debug
 
 # global settings needed all around
 mp_directory = '../mptemp'
@@ -41,12 +38,10 @@
 output_filename = ''
 
 # general debug filter
-dbg = DebugFilter()
+dbg = navidoc.utils.debug.DebugFilter()
 
 # set the default docutils.conf
-if os.path.isfile("./docutils.conf"):
-    docutils = "./docutils.conf"
-else: docutils = ""
+docutils = "./docutils.conf"
 
 # pegs will be sorted after their priority
 pegboard_priorities = {'Current': 1,
Index: navidoc/navidoc/__init__.py
diff -u navidoc/navidoc/__init__.py:1.8 navidoc/navidoc/__init__.py:1.9
--- navidoc/navidoc/__init__.py:1.8     Thu Mar 27 06:56:21 2003
+++ navidoc/navidoc/__init__.py Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: __init__.py,v 1.8 2003/03/27 11:56:21 humppake Exp $
+#$Id: __init__.py,v 1.9 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -27,13 +27,14 @@
 
 __docformat__ = 'reStructuredText'
 
-import docutils.core
 import config
 
+import docutils.core
+
 # 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
+import utils.path
+docutils.utils.relative_path = utils.path.relative_path
 
 def docutils_system_message(self, level, message, *children, **kwargs):
         """
@@ -68,3 +69,30 @@
             self.notify_observers(msg)
         return msg
 docutils.utils.Reporter.system_message = docutils_system_message
+
+class Element:
+    """
+cd     The general element for all subelements.
+    """
+    def __init__(self, list):
+        self.list = list
+
+class NamedElement (Element):
+    """
+    Element with name and linking features.
+    """
+    def do_contents(self, list):
+       for el in list:
+           self.handle_contained(el)
+       dbg("Link: "+self.link)
+    def handle_contained(self, el):
+       if link_types.has_key(el[0]):
+           link = el[1:]
+           if len(link):
+                self.link = link_types[el[0]](link[0][0])
+           else:
+               self.link = self.defaultlink(link[0][0])
+       else:
+            self.list.add_sub_element(self.name, el)
+    def defaultlink(self, link):
+        return link.Link(link)
Index: navidoc/navidoc/directives/__init__.py
diff -u navidoc/navidoc/directives/__init__.py:1.4 
navidoc/navidoc/directives/__init__.py:1.5
--- navidoc/navidoc/directives/__init__.py:1.4  Wed Mar 26 10:36:17 2003
+++ navidoc/navidoc/directives/__init__.py      Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: __init__.py,v 1.4 2003/03/26 15:36:17 humppake Exp $
+# $Id: __init__.py,v 1.5 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -29,15 +29,15 @@
 
 from docutils.parsers.rst import directives
 
-from navidoc.directives.pegboard import pegboard_directive
-from navidoc.directives.latex import bibliography_directive
-#from navidoc.directives.mp import mp_directive, uml_directive, 
uml_refer_directive
+from pegboard import pegboard_directive
+#from latex import bibliography_directive
+#from mp import mp_directive, uml_directive, uml_refer_directive
 
 directives._directives['pegboard'] = pegboard_directive
 #directives._directives['mp'] = mp_directive
 #directives._directives['uml'] = uml_directive
 #directives._directives['uml-refer'] = uml_refer_directive
-directives._directives['bibliography'] = bibliography_directive
+#directives._directives['bibliography'] = bibliography_directive
 
 # some additional options and changes for latex writer
 from docutils.parsers.rst.directives import images
Index: navidoc/navidoc/directives/latex.py
diff -u navidoc/navidoc/directives/latex.py:1.1 
navidoc/navidoc/directives/latex.py:1.2
--- navidoc/navidoc/directives/latex.py:1.1     Wed Mar 26 10:36:17 2003
+++ navidoc/navidoc/directives/latex.py Fri Mar 28 08:08:57 2003
@@ -19,11 +19,13 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: latex.py,v 1.1 2003/03/26 15:36:17 humppake Exp $
+# $Id: latex.py,v 1.2 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Benja Fallenstein
 #
+
+import docutils.nodes
 
 def bibliography_directive(name, arguments, options, content, lineno,
         content_offset, block_text, state, state_machine):
Index: navidoc/navidoc/directives/mp.py
diff -u navidoc/navidoc/directives/mp.py:1.1 
navidoc/navidoc/directives/mp.py:1.2
--- navidoc/navidoc/directives/mp.py:1.1        Wed Mar 26 10:36:17 2003
+++ navidoc/navidoc/directives/mp.py    Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: mp.py,v 1.1 2003/03/26 15:36:17 humppake Exp $
+# $Id: mp.py,v 1.2 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka, Benja Fallenstein
@@ -32,8 +32,8 @@
 
 import config
 
-from navidoc.utils.path import _slashify, relative_path
-from navidoc.mp.core import mp2png, uml
+from navidoc.utils.path import *
+from navidoc.mp import mp2png, create_uml
 
 dbg = config.dbg.shorthand('mp')
 dbg_fail = config.dbg.shorthand('mp.fail')
@@ -49,7 +49,7 @@
     eps_only = config.mp_eps_only # should no png files be generated
 
     attributes = {'name': arguments[0]}
-    options['uri'] = _slashify(to_tmpdir)+attributes['name']
+    options['uri'] = slashify(to_tmpdir)+attributes['name']
     if not eps_only: options['uri'] += '.gen.png'
     else: options['uri'] += '_gen.eps'
     options['alt'] = attributes['name']
@@ -63,7 +63,7 @@
         # XXX fatal error should be made if a diagram with the same name
         # already exists.
 
-        mp_filename = _slashify(config.mp_directory)+attributes['name']
+        mp_filename = slashify(config.mp_directory)+attributes['name']
         if not eps_only: mp = open(mp_filename+'.gen.mp.3', 'w')
         else: mp = open(mp_filename+'_gen.eps', 'w')
         mp.write(temp)
@@ -89,7 +89,7 @@
     eps_only = config.mp_eps_only # should no png files be generated
 
     attributes = {'name': arguments[0]}
-    src = _slashify(to_tmpdir)+attributes['name']
+    src = slashify(to_tmpdir)+attributes['name']
     if not eps_only: src += '.gen.png'
     else: src += '_gen.eps'
 
@@ -123,7 +123,7 @@
         # already exists.
 
         # writes uml and mp sourcefiles and converts them into png and html
-        dir = _slashify(config.mp_directory)
+        dir = slashify(config.mp_directory)
         diagram = attributes['name']
 
         uml_file = open(dir+diagram+'.gen.uml', 'w')
@@ -159,7 +159,7 @@
     eps_only = config.mp_eps_only # should no png files be generated
 
     attributes = {'name': arguments[0]}
-    src = _slashify(to_tmpdir)+attributes['name']
+    src = slashify(to_tmpdir)+attributes['name']
     if not eps_only: src += '.gen.png'
     else: src += '_gen.eps'
 
@@ -180,7 +180,7 @@
     """
     Add reference information for a spesific diagram.
     """
-    refers_filepath = _slashify(config.working_directory)+diagram+".gen.refers"
+    refers_filepath = slashify(config.working_directory)+diagram+".gen.refers"
     if (os.path.isfile(refers_filepath)):
         old_refers = open(refers_filepath, "r").read()
         if old_refers.find(config.output_filename) == -1:
Index: navidoc/navidoc/directives/pegboard.py
diff -u navidoc/navidoc/directives/pegboard.py:1.9 
navidoc/navidoc/directives/pegboard.py:1.10
--- navidoc/navidoc/directives/pegboard.py:1.9  Wed Mar 26 10:36:17 2003
+++ navidoc/navidoc/directives/pegboard.py      Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: pegboard.py,v 1.9 2003/03/26 15:36:17 humppake Exp $
+# $Id: pegboard.py,v 1.10 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Benja Fallensten, Vesa Kaihlavirta, Asko Soukka
@@ -27,16 +27,14 @@
 
 __docformat__ = 'reStructuredText'
 
-import os, string
+import config
 
-from docutils import Component
-from docutils import frontend, io, readers, parsers, writers, nodes
-from docutils.core import publish_cmdline, Publisher
-from docutils.frontend import OptionParser, ConfigParser
+import os, string
 
-import config
+from docutils import nodes
+from docutils.core import Publisher
 
-from navidoc.utils.path import _slashify
+from navidoc.utils.path import *
 
 dbg = config.dbg.shorthand('pegboard')
 dbg_fail = config.dbg.shorthand('pegboard.fail')
@@ -112,20 +110,20 @@
     pegtable = []
 
     pegdirs = [d for d in os.listdir(config.working_directory)
-           if os.path.isdir(_slashify(config.working_directory)+d) and d != 
'CVS']
+           if os.path.isdir(slashify(config.working_directory)+d) and d != 
'CVS']
 
     init_working_directory = config.working_directory
 
     for pegdir in pegdirs:
         dbg('processing PEG ' + pegdir)
-        config.working_directory = _slashify(init_working_directory)+pegdir
+        config.working_directory = slashify(init_working_directory)+pegdir
         
         peg = {'authors': [], 'status': config.pegboard_undefined, 'topic': 
pegdir,
                'stakeholders': [], 'last-modified': '', 'dir': pegdir, 
'files': '',
                'html': '', 'rst': '', 'rstfiles': [], 'ignore': [] }
         
         peg['files'] = [f for f in os.listdir(config.working_directory) \
-                        if 
os.path.isfile(_slashify(config.working_directory)+f)
+                        if os.path.isfile(slashify(config.working_directory)+f)
                         and not f.startswith('.') and '#' not in f and '~' not 
in f]
 
         if peg['files'].count('peg.rst') > 0:
@@ -142,7 +140,7 @@
             config.output_filename = ''
             pub = Publisher()
             pub.set_reader('standalone', None, 'restructuredtext')
-            filename = _slashify(config.working_directory)+rstfile
+            filename = slashify(config.working_directory)+rstfile
             pub.process_command_line(argv=('--config '+config.docutils+' 
'+filename+'').split())
             
             #conversion may fail because of bad restructuredtext
Index: navidoc/navidoc/link/__init__.py
diff -u navidoc/navidoc/link/__init__.py:1.2 
navidoc/navidoc/link/__init__.py:1.3
--- navidoc/navidoc/link/__init__.py:1.2        Thu Mar 27 04:33:48 2003
+++ navidoc/navidoc/link/__init__.py    Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: __init__.py,v 1.2 2003/03/27 09:33:48 humppake Exp $
+#$Id: __init__.py,v 1.3 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Tuomas Lukka, Asko Soukka
@@ -27,8 +27,6 @@
 
 __docformat__ = 'reStructuredText'
 
-from navidoc.parser import *
-
 import config
 
 from navidoc.utils.path import *
@@ -94,8 +92,8 @@
 #             settings2 = settings.copy()
 #             if settings.has_key('path') and settings.has_key('tmpdir') \
 #                    and settings.has_key('name'):
-#                 if 
(os.path.isfile(mputils._slashify(settings['tmpdir'])+settings['name']+".gen.refers")):
-#                     refer_file = 
open(mputils._slashify(settings['tmpdir'])+settings['name']\
+#                 if 
(os.path.isfile(mputils.slashify(settings['tmpdir'])+settings['name']+".gen.refers")):
+#                     refer_file = 
open(mputils.slashify(settings['tmpdir'])+settings['name']\
 #                                       +".gen.refers", "r")
 #                     #print "NEEDLE:", ts[-3].split("/")[-1]
 #                     refers = refer_file.readlines()
Index: navidoc/navidoc/modules/metalink.py
diff -u navidoc/navidoc/modules/metalink.py:1.2 
navidoc/navidoc/modules/metalink.py:1.3
--- navidoc/navidoc/modules/metalink.py:1.2     Fri Mar 21 05:36:28 2003
+++ navidoc/navidoc/modules/metalink.py Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: metalink.py,v 1.2 2003/03/21 10:36:28 humppake Exp $
+#$Id: metalink.py,v 1.3 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -29,7 +29,7 @@
 
 import os.path
 
-from navidoc.utils.path import _slashify, _listdir
+from navidoc.utils.path import *
 
 def postprocess(path):
     """
@@ -37,20 +37,20 @@
     target filename.
     """
 
-    dirlist = _listdir(path, "html", dirs=1)
+    dirlist = listdir(path, "html", dirs=1)
     dirlist.sort()
     location = 0
 
     for entry in dirlist:        
-        if os.path.isdir(_slashify(path)+entry) \
-               and not os.path.islink(_slashify(path)+entry):
-            postprocess(_slashify(path)+entry)
+        if os.path.isdir(slashify(path)+entry) \
+               and not os.path.islink(slashify(path)+entry):
+            postprocess(slashify(path)+entry)
 
-        if os.path.isfile(_slashify(path)+entry):
-            html = open(_slashify(path)+entry).read()
+        if os.path.isfile(slashify(path)+entry):
+            html = open(slashify(path)+entry).read()
 
             insert = html.lower().find("</head>")
-            out = open(_slashify(path)+entry, "w")
+            out = open(slashify(path)+entry, "w")
             out.write(html[0:insert])
 
             #out.write('<meta name="robots" content="noarchive, noindex, 
nofollow" />'+"\n")
Index: navidoc/navidoc/modules/navbar.py
diff -u navidoc/navidoc/modules/navbar.py:1.5 
navidoc/navidoc/modules/navbar.py:1.6
--- navidoc/navidoc/modules/navbar.py:1.5       Fri Mar 28 05:00:38 2003
+++ navidoc/navidoc/modules/navbar.py   Fri Mar 28 08:08:57 2003
@@ -1,4 +1,4 @@
-# 
+x# 
 # Copyright (c) 2003 by Benja Fallenstein
 # 
 # This file is part of Navidoc.
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: navbar.py,v 1.5 2003/03/28 10:00:38 benja Exp $
+#$Id: navbar.py,v 1.6 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Benja Fallenstein
@@ -27,11 +27,11 @@
 
 __docformat__ = 'reStructuredText'
 
-import re, os
-
 import config
 
-from navidoc.utils.path import _slashify
+import re, os
+
+from navidoc.utils.path import *
 
 dbg = config.dbg.shorthand('navbar')
 
@@ -92,7 +92,7 @@
     for el in tree.files:
         if el[0].endswith('index.html'): continue
         s += '<li class="boxitem"><a href="%s">%s</a></li>\n' % \
-             (el[0][len(_slashify(config.working_directory)):len(el[0])], 
el[1])
+             (el[0][len(slashify(config.working_directory)):len(el[0])], el[1])
         if len(el) > 2:
             s += simpleNavbar(el[2], indent+"&nbsp;&nbsp;")
     return s
Index: navidoc/navidoc/mp/__init__.py
diff -u navidoc/navidoc/mp/__init__.py:1.5 navidoc/navidoc/mp/__init__.py:1.6
--- navidoc/navidoc/mp/__init__.py:1.5  Thu Mar 27 06:56:21 2003
+++ navidoc/navidoc/mp/__init__.py      Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: __init__.py,v 1.5 2003/03/27 11:56:21 humppake Exp $
+# $Id: __init__.py,v 1.6 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Tuomas Lukka, Asko Soukka
@@ -27,14 +27,12 @@
 
 __docformat__ = 'reStructuredText'
 
-import os, os.path
-
 import config
 
-import navidoc.link
+import os, os.path
+import navidoc.link, navidoc.parser
 
 from navidoc.utils.path import *
-from navidoc.parser import NamedElement
 
 dbg = config.dbg.shorthand('mp')
 dbg_fail = config.dbg.shorthand('mp.fail')
@@ -47,7 +45,7 @@
         else: return 'showfocus("'+target+'", '+title+', ('+box+'));'
 navidoc.link.Link.draw_code = link_draw_code
 
-class NamedMPElement(NamedElement):
+class MetaPostElement(navidoc.parser.NamedElement):
     def repl(self, s):
        s = s.replace("%%", self.var)
        s = s.replace("%name%", self.name)
@@ -60,7 +58,7 @@
            """
        return self.repl(s)
 
-class SimpleElement(NamedMPElement):
+class SimpleElement(MetaPostElement):
     def __init__(self, var, s, list):
        dbg("Simple element: %s %s %s" % (self, s, list))
        self.var = var or s
@@ -70,18 +68,18 @@
 def create_uml(diagram, extension='', scale=1.0):
     """
     """
-    if not os.path.isfile(_slashify(config.mp_directory)+diagram+'.gen.uml'):
-        raise 
MetapostException(_slashify(config.mp_directory)+diagram+'.gen.uml'+' not 
found')
-    if not os.path.isfile(_slashify(config.mp_directory)+diagram+'.gen.mp'):
-        raise 
MetapostException(_slashify(config.mp_directory)+diagram+'.gen.mp'+' not found')
+    if not os.path.isfile(slashify(config.mp_directory)+diagram+'.gen.uml'):
+        raise 
MetapostException(slashify(config.mp_directory)+diagram+'.gen.uml'+' not found')
+    if not os.path.isfile(slashify(config.mp_directory)+diagram+'.gen.mp'):
+        raise 
MetapostException(slashify(config.mp_directory)+diagram+'.gen.mp'+' not found')
     
-    s = open(_slashify(config.mp_directory)+diagram+'.gen.uml').read()
+    s = open(slashify(config.mp_directory)+diagram+'.gen.uml').read()
     l = parseIndented(s)
     m = mplist(l)
 
     if len(extension) > 0: extension = '_'+extension
 
-    dir = _slashify(config.mp_directory)
+    dir = slashify(config.mp_directory)
     gen1 = open(dir+diagram+extension+'.gen.mp.1', 'w')
     gen1.write(m.setupCode()+'\n')
     gen1.close()
@@ -118,7 +116,7 @@
     dbg(syscmd)
     os.system('cd '+config.mp_directory+';'+syscmd)
 
-    log = open(_slashify(config.mp_directory)+diagram+'.gen.log').read()
+    log = open(slashify(config.mp_directory)+diagram+'.gen.log').read()
     if log.find("\n"+'!') != -1:
         dbg_fail('Error occurred while processing the diagram. The log is 
shown below.')
         dbg_fail(log)
@@ -147,9 +145,9 @@
 
     scaling = int(scaling / scale)
 
-    syscmd = ('pstopnm '+' '.join(list)+' 
<'+_slashify(config.mp_directory)+diagram+'.gen' \
+    syscmd = ('pstopnm '+' '.join(list)+' 
<'+slashify(config.mp_directory)+diagram+'.gen' \
               +'.mp.1 2>/dev/null | pnmscale -reduce '+scaling+' 2>/dev/null | 
' \
-              +'pnmtopng >'+_slashify(config.mp_directory)+diagram+'.gen.png 
2>/dev/null')
+              +'pnmtopng >'+slashify(config.mp_directory)+diagram+'.gen.png 
2>/dev/null')
 
     dbg(syscmd)
     os.system(syscmd)
Index: navidoc/navidoc/mp/uml.py
diff -u navidoc/navidoc/mp/uml.py:1.2 navidoc/navidoc/mp/uml.py:1.3
--- navidoc/navidoc/mp/uml.py:1.2       Thu Mar 27 04:33:48 2003
+++ navidoc/navidoc/mp/uml.py   Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: uml.py,v 1.2 2003/03/27 09:33:48 humppake Exp $
+# $Id: uml.py,v 1.3 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Tuomas Lukka, Asko Soukka
@@ -27,13 +27,11 @@
 
 __docformat__ = 'reStructuredText'
 
-#from __future__ import nested_scopes
-import re, os, sys, random, string
+import config
 
-from navidoc.mp.core import *
-from navidoc.parser import *
+import re
 
-import config
+from navidoc.parser import *
 
 dbg = config.dbg.shorthand('uml')
 
@@ -169,7 +167,7 @@
        s = s.replace("%%", self.var)
        return s
 
-class mpclass(NamedMPElement):
+class mpclass(MetaPostElement):
     key = 'class'
     def __init__(self, var, s, list):
        dbg("mpclass: %s %s" % (s,list))
@@ -190,7 +188,7 @@
        elif el[0] == "fields":
            self.fields = el[1:]
        else:
-           NamedMPElement.handle_contained(self, el)
+           MetaPostElement.handle_contained(self, el)
     def defaultlink(self):
        if self.linkpackage != None and "." not in self.name:
            return self.linkpackage + "." + self.name
@@ -236,7 +234,7 @@
            """ 
        return self.repl(s)
 
-class mppackage(NamedMPElement):
+class mppackage(MetaPostElement):
     key = 'package'
     def __init__(self, var, s, list):
        dbg("mppackage: %s %s" % (s,l))
@@ -258,7 +256,7 @@
            """ 
        return self.repl(s)
 
-class mptitle(NamedMPElement):
+class mptitle(MetaPostElement):
     key = 'title'
     def __init__(self, var, s, l = []):
        dbg("mp: %s %s" % (s,l))
@@ -377,7 +375,7 @@
             drawmeasuredpic(%%.titl);"""
        return self.repl(s)
 
-class mpqual(NamedMPElement):
+class mpqual(MetaPostElement):
     key = 'qual'
     def __init__(self, var, s , list):
        self.var = var
@@ -388,7 +386,7 @@
        if el[0] == "fields":
            self.fields = el[1:]
        else:
-           NamedMPElement.handle_contained(self, el)
+           MetaPostElement.handle_contained(self, el)
     def setup_code(self):
        s = """
            picture %%.pict;
@@ -400,9 +398,9 @@
            [ '"'+m[0]+'"' for m in self.fields ] ))
        return self.repl(s)
 
-class mpassoc(NamedMPElement):
+class mpassoc(MetaPostElement):
     key = 'assoc'
-    class end(NamedMPElement):
+    class end(MetaPostElement):
        def __init__(self, var, list):
            self.var = var
            self.name = ""
@@ -493,7 +491,7 @@
        self.b.type = "vobinto"
 
 
-class SimpleRelation(NamedMPElement):
+class SimpleRelation(MetaPostElement):
     def __init__(self, var, s , list):
        self.var = var or random_var()
        self.name = ""
@@ -553,7 +551,7 @@
     def draw_code(self):
        return self.pathCode() + self.repl(" vobsubmatch(%%.p); ")
 
-class placement(NamedMPElement):
+class placement(MetaPostElement):
     def __init__(self, var, s , list):
        self.var = var or random_var()
        self.name = ""
Index: navidoc/navidoc/parser.py
diff -u navidoc/navidoc/parser.py:1.5 navidoc/navidoc/parser.py:1.6
--- navidoc/navidoc/parser.py:1.5       Fri Mar 28 01:44:41 2003
+++ navidoc/navidoc/parser.py   Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-# $Id: parser.py,v 1.5 2003/03/28 06:44:41 humppake Exp $
+# $Id: parser.py,v 1.6 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Tuomas Lukka, Asko Soukka
@@ -27,136 +27,50 @@
 
 __docformat__ = 'reStructuredText'
 
-#from __future__ import nested_scopes
-import re, random, string
-
-import navidoc.mp, navidoc.link
-
 import config
 
-dbg = config.dbg.shorthand('parser')
-
-element_types = {}
-link_types = {}
-
-def __init__():
-    """
-    Gather available elements and linktypes from modules.
-    """
-    #XXX: Fix key-name conflicts
-    element_types.update(keys4classes(navidoc.mp))
-    for module in dir(navidoc.mp):
-        module = getattr(navidoc.mp, module)
-        element_types.update(keys4classes(module))
-
-    link_types.update(keys4classes(navidoc.link))
-    for module in dir(navidoc.link):
-        module = getattr(navidoc.link, module)
-        link_types.update(keys4classes(module))
-
-def keys4classes(module):
-    """
-    Gather a key -> class dictionary for all classes containing
-    'key' in sub modules under root module.
-    """
-    d = {}
-    for elements in dir(module):
-        for element in elements:
-            element = getattr(module, element)
-            if hasattr(element, "key") \
-                   and type(element.key) == type(''):
-                d[element.key] = element
-    return d
-
-class ParserException(Exception):
-    def __init__(self, value):
-        Exception.__init__()
-        self.value = value
-    def __str__(self):
-        return self.value
-
-def match_remove(p, s):
-    """
-    Match pattern p in s and remove the match, return (match, ns)
-    """
-    m = re.match(p,s)
-    if m: s = re.sub(p, "", s)
-    return (m, s)
-
-def resolve_tabs(s):
-    """
-    Transform tabs into spaces. Return the transformed string.
-    """
-    return re.sub("\t", "        ", s);
+import mp, link
+from utils.parser import *
 
-def init_spaces(s):
-    """
-    Strip whitespaces and calculates the amount of them in the
-    beginning of the string. Return the amount and stripped
-    string.
-    """
-    n = len(re.match("^\s*", s).group())
-    return (n, s.strip())
+dbg = config.dbg.shorthand('parser')
 
-def random_var():
-    """
-    Return a 20 random character string.
-    """
-    l = len(string.letters)
-    return "".join([
-       string.letters[random.randint(0, l-1)] 
-           for k in range(20)])
+class ElementFactor:
 
-def parse_indented(s):
-    """
-    Split the string into lines after "\n"s. Parse the string
-    array into array tree after indentions in consecutive strings.
-    Return the parsed array.
-    """
-    stack = [(-1, [])]
-    for r in s.split("\n") :
-       if re.match("^\s*$", r): continue
-       r = resolve_tabs(r) 
-       (n,x) = init_spaces(r)
-       while n < stack[-1][0]:
-           stack.pop()
-       if n > stack[-1][0]:
-           new = (n, [x])
-           stack[-1][1].append(new[1])
-           stack.append(new)
-       else: # x == stack[-1][0]:
-           new = (n, [x])
-           stack[-2][1].append(new[1])
-           stack.pop()
-           stack.append(new)
-    return stack[0][1]
-
-class Element:
-    """
-    The general element for all subelements.
-    """
-    def __init__(self, list):
-        self.list = list
+    element_types = {}
+    link_types = {}
 
-class NamedElement (Element):
-    """
-    Element with name and linking features.
-    """
-    def do_contents(self, list):
-       for el in list:
-           self.handle_contained(el)
-       dbg("Link: "+self.link)
-    def handle_contained(self, el):
-       if link_types.has_key(el[0]):
-           link = el[1:]
-           if len(link):
-                self.link = link_types[el[0]](link[0][0])
-           else:
-               self.link = self.defaultlink(link[0][0])
-       else:
-            self.list.add_sub_element(self.name, el)
-    def defaultlink(self, link):
-        return navidoc.link.Link(link)
+    def __init__(self):
+        """
+        Gather available elements and linktypes from modules.
+        """
+        #XXX: Fix key-name conflicts
+        element_types.update(keys4classes(navidoc.mp))
+        for module in dir(navidoc.mp):
+            module = getattr(navidoc.mp, module)
+            if type(module) == type(navidoc.parser):
+                print module
+                element_types.update(keys4classes(module))
+
+        #    link_types.update(keys4classes(navidoc.link))
+        #    for module in dir(navidoc.link):
+        #        module = getattr(navidoc.link, module)
+        #        link_types.update(keys4classes(module))
+
+        def keys4classes(self.module):
+            """
+            Gather a key -> class dictionary for all classes containing
+            'key' in sub modules under root module.
+            """
+            d = {}
+            for element in dir(module):
+                element = getattr(module, element)
+                if type(element) == type(Element) \
+                       and issubclass(element, Element):
+                    print element
+                    if hasattr(element, "key") \
+                           and type(element.key) == type(''):
+                        d[element.key] = element
+            return d
 
 class ElementList:
     """
@@ -219,4 +133,11 @@
        "Return code to draw the objects after the user code"
        code = "\n".join([element.draw_code() for element in self.list]) + "\n"
        return code
+
+class ParserException(Exception):
+    def __init__(self, value):
+        Exception.__init__()
+        self.value = value
+    def __str__(self):
+        return self.value
 
Index: navidoc/navidoc/utils/path.py
diff -u navidoc/navidoc/utils/path.py:1.6 navidoc/navidoc/utils/path.py:1.7
--- navidoc/navidoc/utils/path.py:1.6   Wed Mar 26 10:36:17 2003
+++ navidoc/navidoc/utils/path.py       Fri Mar 28 08:08:57 2003
@@ -19,7 +19,7 @@
 # MA  02111-1307  USA
 # 
 
-#$Id: path.py,v 1.6 2003/03/26 15:36:17 humppake Exp $
+#$Id: path.py,v 1.7 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -29,7 +29,7 @@
 
 import os.path
 
-def _listdir(path, extensions, dirs=0):
+def listdir(path, extensions, dirs=0):
     """
     Returns all directories and files with specific
     extensions under path. Nonrecursive.
@@ -38,12 +38,12 @@
              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)]
+             or os.path.isdir(slashify(path)+f)]
     if not dirs:
-        files = [f for f in files if os.path.isfile(_slashify(path)+f)]
+        files = [f for f in files if os.path.isfile(slashify(path)+f)]
     return files
 
-def _slashify(path):
+def slashify(path):
     """
     Add a trailing slash if not already there.
     """
Index: navidoc/rst2any.py
diff -u navidoc/rst2any.py:1.15 navidoc/rst2any.py:1.16
--- navidoc/rst2any.py:1.15     Thu Mar 27 06:56:21 2003
+++ navidoc/rst2any.py  Fri Mar 28 08:08:57 2003
@@ -21,7 +21,7 @@
 # MA  02111-1307  USA
 # 
 
-#$id:$
+#$Id: rst2any.py,v 1.16 2003/03/28 13:08:57 humppake Exp $
 
 #
 # Written by Asko Soukka
@@ -29,15 +29,16 @@
 
 __docformat__ = 'reStructuredText'
 
+import config
+
 import sys, os, getopt
 import docutils.core
 
-import config
-
 import navidoc.directives
-import navidoc.writers
+#import navidoc.writers
+import navidoc.modules
 
-from navidoc.utils.path import _slashify, _listdir
+from navidoc.utils.path import *
 
 """
 The main frontend for running Navidoc.
@@ -126,11 +127,11 @@
     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)
-        if os.path.isfile(_slashify(path) + 'docutils.conf'):
-            config.docutils = _slashify(path) + 'docutils.conf'
+       dirlist = listdir(path,['rst'],dirs=1)
+        if os.path.isfile(slashify(path) + 'docutils.conf'):
+            config.docutils = slashify(path) + 'docutils.conf'
         for entry in dirlist:
-            run_docutils(_slashify(path)+entry)
+            run_docutils(slashify(path)+entry)
     elif os.path.isfile(path):
         config.working_directory = os.path.normpath(os.path.dirname(path))
         config.input_filename = os.path.basename(path)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]