[gcompris/gcomprixogoo] Can run the new model for wiktion2xml on the full wiktionary like before.



commit b080ff1cabe26514d0fdb584a8bafd2cb30f0902
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Mon Oct 11 00:47:47 2010 +0200

    Can run the new model for wiktion2xml on the full wiktionary like before.

 tools/wiktio2xml/wiktio.py     |    4 +---
 tools/wiktio2xml/wiktio2xml.py |   19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/tools/wiktio2xml/wiktio.py b/tools/wiktio2xml/wiktio.py
index 617673f..f11f8ab 100644
--- a/tools/wiktio2xml/wiktio.py
+++ b/tools/wiktio2xml/wiktio.py
@@ -56,12 +56,10 @@ class Description:
 
     # Recursively find the node at the given level
     def getNodeAtLevel(self, level):
-        if level == self.level:
+        if level >= self.level:
             return self
         elif level < self.level:
             return self.parent.getNodeAtLevel(level)
-        else:
-            return None
 
     def addDescription(self, text, level, numbered):
         node = self.getNodeAtLevel(level - 1)
diff --git a/tools/wiktio2xml/wiktio2xml.py b/tools/wiktio2xml/wiktio2xml.py
index 1569a50..cab9e16 100755
--- a/tools/wiktio2xml/wiktio2xml.py
+++ b/tools/wiktio2xml/wiktio2xml.py
@@ -21,6 +21,7 @@ from xml.sax import parse
 from xml.sax.handler import ContentHandler
 import sys
 import re
+import os
 
 from optparse import OptionParser
 
@@ -439,9 +440,12 @@ parser.add_option("-o", "--output", dest="output",
                   help="write result to file or directory")
 parser.add_option("-q", "--quiet",
                   action="store_false", dest="verbose", default=True,
-                  help="don't print status messages to stdout")
+                  help="don't print in progress messages to stdout")
+parser.add_option("-d", "--debug",
+                  action="store_true", dest="debug", default=False,
+                  help="print debug traces to stdout")
 parser.add_option("-s", "--site",
-                  action="store_false", dest="site", default=False,
+                  action="store_true", dest="site", default=False,
                   help="Creates a web site")
 (options, args) = parser.parse_args()
 
@@ -452,6 +456,15 @@ if len(sys.argv) < 3:
 wikiFile = sys.argv[1]
 wordsFile = sys.argv[2]
 
+if options.site:
+    if not os.path.isdir(options.output):
+        print "ERROR: There must me a directory named " + options.output
+        sys.exit(1)
+else:
+    if os.path.exists(options.output):
+        print "ERROR: There is already a file named " + options.output
+        sys.exit(1)
+
 # Import the list of words
 f = open(wordsFile, "r")
 words = []
@@ -462,6 +475,8 @@ _wiktio = wiktio.Wiktio()
 
 parse(wikiFile, WikiHandler(words, 'fr', _wiktio, options.verbose))
 
+debug = options.debug
+
 if options.site:
     _wiktio.dump2htmlSite(options.output)
 else:



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