summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2009-12-20 22:53:52 -0500
committerKohei Yoshida <kyoshida@novell.com>2009-12-20 22:53:52 -0500
commit617c026ff70fd6d3ae61bd27d5447f851414fd2e (patch)
tree76589a1fb01864458097ce9539284e2e6568f8da
parent7cd58828d2f7819610bc4820959af1e47809a796 (diff)
Fixed incorrect encoding of symbols & handle directory walking myself.
-rwxr-xr-xooo-help-parser.py20
-rw-r--r--source/expatimpl.py9
2 files changed, 19 insertions, 10 deletions
diff --git a/ooo-help-parser.py b/ooo-help-parser.py
index d91f08c..c96dee0 100755
--- a/ooo-help-parser.py
+++ b/ooo-help-parser.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-import sys, os.path, optparse
+import sys, os, os.path, optparse
sys.path.append(sys.path[0]+"/source")
import globals, expatimpl
@@ -14,6 +14,18 @@ def main ():
parser.print_help()
sys.exit(1)
+ filepaths = []
+ for fpath in args:
+ if os.path.isdir(fpath):
+ # get all .xhp files recursively under this directory.
+ for root, dirs, files in os.walk(fpath):
+ for file in files:
+ if os.path.splitext(file)[1] == '.xhp':
+ filepaths.append(root + '/' + file)
+ elif os.path.isfile(fpath):
+ if os.path.splitext(fpath)[1] == '.xhp':
+ filepaths.append(os.path.abspath(fpath))
+
fd = sys.stdout
if options.output != None:
if os.path.isdir(options.output):
@@ -22,11 +34,7 @@ def main ():
fd = open(options.output, 'w')
filesParsed = 0
- for fpath in args:
- if not os.path.isfile(fpath):
- globals.error(fpath + " is not a valid file. Skipping.")
- continue
-
+ for fpath in filepaths:
# globals.info("processing " + fpath)
file = open(fpath, 'r')
strm = file.read()
diff --git a/source/expatimpl.py b/source/expatimpl.py
index 5d10569..295d88a 100644
--- a/source/expatimpl.py
+++ b/source/expatimpl.py
@@ -121,24 +121,25 @@ class Parser:
if node.nodeType == NodeType.Node:
hasChildren = len(node.children) > 0
- line = "<%s"%node.name
+ # We add '<' and '>' (or '/>') after the element content gets
+ # encoded.
+ line = node.name
if len(node.attrs) > 0:
keys = node.attrs.keys()
keys.sort()
for key in keys:
line += " " + key + '="' + node.attrs[key] + '"'
if hasChildren and not nodesToSkip.has_key(node.name):
- line += ">\n"
line = encodeString(line)
+ line = "<%s>\n"%line
fd.write (indent + line)
for child in node.children:
self.printNode(fd, child, level+1)
line = "</%s>\n"%node.name
- line = encodeString(line)
fd.write (indent + line)
else:
- line += "/>\n"
line = encodeString(line)
+ line = "<%s/>\n"%line
fd.write (indent + line)
elif node.nodeType == NodeType.Content: