summaryrefslogtreecommitdiff
blob: 902e4f8221585e6302504aa89a0e3e654e7db1d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Use native python instead of external pyxml dependency.  Patch from Debian.

https://bugs.gentoo.org/367733


--- a/README.txt
+++ b/README.txt
@@ -15,9 +15,8 @@ universal and easy to use for desktop users and developers.
 Requirements
 ~~~~~~~~~~~~
 
-   - Python >= 2.3
-   - wxPython 2.6
-   - python-xml (PyXML)
+   - Python >= 2.4
+   - wxPython >= 2.6
    - gettext >= 0.14
 
 
--- a/lib/xmltools.py
+++ b/lib/xmltools.py
@@ -20,7 +20,6 @@
 #
 
 import xml.dom.minidom
-import xml.dom.ext
 
 from lib import meta
 
@@ -30,7 +29,7 @@ def _textData(element):
 
     text = ''
     for node in element.childNodes:
-        text = node.data
+        text = node.data.strip()
 
     return text
 
@@ -99,7 +98,7 @@ class RegisterConfigGenerator:
                                                    or ''))
 
         return doc
-    
+
 
 def generatePlainDictConfig(**args):
     """Generate configuration and return DOM object"""
@@ -113,10 +112,11 @@ def generatePlainDictConfig(**args):
 def writePlainDictConfig(doc, path):
     """Write XML file"""
 
-    fd = open(path, 'w')
-    xml.dom.ext.PrettyPrint(doc, fd)
+    import codecs
+    fd = codecs.open(path, 'w', 'utf-8')
+    doc.writexml(fd, addindent = "  ", newl = "\n", encoding = "UTF-8")
     fd.close()
-    
+
 
 
 class RegisterConfigParser:
@@ -144,32 +144,32 @@ class RegisterConfigParser:
         
         for nameElement in registerElement.getElementsByTagName('name'):
             for node in nameElement.childNodes:
-                name = node.data
+                name = node.data.strip()
 
         for formatElement in registerElement.getElementsByTagName('format'):
             for node in formatElement.childNodes:
-                format = node.data
+                format = node.data.strip()
 
         for pathElement in registerElement.getElementsByTagName('path'):
             for node in pathElement.childNodes:
-                path = node.data
+                path = node.data.strip()
 
         for versionElement in registerElement.getElementsByTagName('version'):
             for node in versionElement.childNodes:
                 version = node.data.strip()
 
         for authorElement in registerElement.getElementsByTagName('author'):
-            authors.append({'name': authorElement.getAttribute('name'),
-                            'email': authorElement.getAttribute('email')})
+            authors.append({'name': authorElement.getAttribute('name').strip(),
+                            'email': authorElement.getAttribute('email').strip()})
 
         for md5Element in registerElement.getElementsByTagName('md5'):
             for node in md5Element.childNodes:
-                md5 = node.data
+                md5 = node.data.strip()
 
         for encodingElement in \
                 registerElement.getElementsByTagName('encoding'):
             for node in encodingElement.childNodes:
-                encoding = node.data
+                encoding = node.data.strip()
 
         for licenceElement in \
                 registerElement.getElementsByTagName('licence'):
@@ -241,8 +241,9 @@ def generateIndexFile(index):
 def writeIndexFile(doc, path):
     """Write XML file"""
 
-    fd = open(path, 'wb')
-    xml.dom.ext.PrettyPrint(doc, fd)
+    import codecs
+    fd = codecs.open(path, 'wb', 'utf-8')
+    doc.writexml(fd, addindent = "  ", newl = "\n", encoding = "UTF-8")
     fd.close()
 
 
@@ -511,7 +512,8 @@ def generateMainConfig(props):
 def writeConfig(doc, path):
     """Write XML file"""
 
-    fd = open(path, 'w')
-    xml.dom.ext.PrettyPrint(doc, fd)
+    import codecs
+    fd = codecs.open(path, 'w', 'utf-8')
+    doc.writexml(fd, addindent = "  ", newl = "\n", encoding = "UTF-8")
     fd.close()
 
--- a/opendict.py
+++ b/opendict.py
@@ -53,16 +53,6 @@ except ImportError:
     print >> sys.stderr, "**"
     sys.exit(1)
 
-
-try:
-    import xml.dom.ext
-except ImportError:
-    print >> sys.stderr, "**"
-    print >> sys.stderr, "** Error: Python/XML library not found"
-    print >> sys.stderr, "** Please install python-xml (PyXML) to run OpenDict"
-    print >> sys.stderr, "**"
-    sys.exit(1)
-
 # get_main_dir() returns the directory name of the script or the
 # directory name of the exe
 def get_main_dir():