summaryrefslogtreecommitdiff
blob: d79edc3e5c1e8aed29a77d34b5ca24ba66762c57 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
=== modified file 'Makefile.am'
--- Makefile.am	2007-08-13 15:30:11 +0000
+++ Makefile.am	2008-03-07 16:05:24 +0000
@@ -34,6 +34,7 @@
 	serpentine/common.py        \
 	serpentine/urlutil.py       \
 	serpentine/errors.py        \
+	serpentine/compatxml.py     \
 	serpentine/release.py
 
 serpentine_pluginsdir = $(pythondir)/serpentine/plugins

=== modified file 'serpentine/__init__.py'
--- serpentine/__init__.py	2007-10-15 10:55:52 +0000
+++ serpentine/__init__.py	2008-03-07 16:05:24 +0000
@@ -458,7 +458,7 @@
         """
         # Clean window object
         Application.stop(self)
-        self.__window.destroy()
+#        self.__window.destroy()
         del self.__window
         
 

=== added file 'serpentine/compatxml.py'
--- serpentine/compatxml.py	1970-01-01 00:00:00 +0000
+++ serpentine/compatxml.py	2008-03-07 16:05:24 +0000
@@ -0,0 +1,29 @@
+"""
+Compability layer of XML.
+"""
+try:
+	from Ft.Xml.Domlette import NonvalidatingReader
+	parseUri = NonvalidatingReader.parseUri
+        parseString = NonvalidatingReader.parseString
+	del NonvalidatingReader
+	from Ft.Xml.XPath import Evaluate
+except ImportError:
+	from xml.dom.minidom import parse as parseUri
+	from xml.dom.minidom import parseString
+	from xml.xpath import Evaluate
+
+def get_node_attr(node, attr):
+	"""
+	Tries to uniform the way to get the *value* of an attribute in
+	both minidom and in 4Suite.
+	"""
+	try:
+		return node.attributes[attr].value
+	except KeyError:
+		return node.attributes[(None, attr)].value
+
+def node_contains_attr(node, attr):
+	"""
+	Uniforms the attributes in both minidom and in 4Suite.
+	"""
+	return attr in node.attributes or (None, attr) in node.attributes

=== modified file 'serpentine/plugins/plugfilter_k3b.py'
--- serpentine/plugins/plugfilter_k3b.py	2007-08-02 17:26:16 +0000
+++ serpentine/plugins/plugfilter_k3b.py	2008-03-07 16:05:24 +0000
@@ -21,8 +21,8 @@
 
 import zipfile, gnomevfs
 
-from xml.dom import minidom
-from xml.xpath import Evaluate
+from serpentine.compatxml import parseString, Evaluate, get_node_attr
+
 from xml.parsers.expat import ExpatError
 
 from serpentine.mastering import HintsFilter
@@ -70,7 +70,7 @@
         try:
             zfile = zipfile.ZipFile(fd)
             buff = zfile.read("maindata.xml")
-            root = minidom.parseString(buff)
+            root = parseString(buff)
             
         except (zipfile.BadZipfile, IOError, KeyError, ExpatError):
             raise UnsupportedLocationError()
@@ -81,7 +81,7 @@
         hints_list = []
         for node in Evaluate ("/k3b_audio_project/contents/track", root):
             try:
-                hints_list.append ({"location": node.attributes["url"].value})
+                hints_list.append ({"location": get_node_attr(node, "url")})
             except KeyError:
                 # skip elements without the 'url' attribute set
                 pass
@@ -92,9 +92,8 @@
         for node in Evaluate ("/k3b_audio_project/contents/track/sources/file",
                               root):
             try:
-                hints_list.append ({"location": node.attributes["url"].value})
+                hints_list.append ({"location": get_node_attr(node, "url")})
             except KeyError:
-                # skip elements with not 'url' attribute set
                 pass
 
         return hints_list

=== modified file 'serpentine/plugins/plugrhythmbox.py'
--- serpentine/plugins/plugrhythmbox.py	2007-08-14 08:43:07 +0000
+++ serpentine/plugins/plugrhythmbox.py	2008-03-07 16:05:24 +0000
@@ -3,8 +3,8 @@
 import os.path
 import weakref
 
-from xml.xpath import Evaluate
-from xml.dom import minidom
+from serpentine.compatxml import Evaluate, parseUri, get_node_attr, node_contains_attr
+
 from gettext import gettext as _
 
 if __name__ == '__main__':
@@ -20,17 +20,17 @@
 
 def rhythmbox_list_names():
     try:
-        root = minidom.parse(PLAYLISTS)
+        root = parseUri(PLAYLISTS)
     except IOError:
         return ()
     
     nodes = Evaluate("/rhythmdb-playlists/playlist", root)
-    return [node.attributes["name"].value for node in nodes]
+    return [get_node_attr(node, "name") for node in nodes if node_contains_attr(node, "name")]
 
 
 def rhythmbox_get_playlist(playlist_name):
     try:
-        root = minidom.parse(PLAYLISTS)
+        root = parseUri(PLAYLISTS)
     except IOError:
         return ()
     

=== modified file 'serpentine/xspf.py'
--- serpentine/xspf.py	2007-08-02 17:20:48 +0000
+++ serpentine/xspf.py	2008-03-07 16:05:24 +0000
@@ -23,8 +23,8 @@
 This is a very simple utility module for retrieving basic XSPF playlist data.
 Basically it retrieves the playlist tracks' title, artist, location and duration.
 """
-from xml.dom import minidom
-from xml.xpath import Evaluate
+
+from serpentine.compatxml import parseUri, Evaluate
 from xml.dom.minidom import getDOMImplementation
 
 class _Field(object):
@@ -121,7 +121,8 @@
 		return doc
 
 	def parse (self, file_or_filename):
-		root = minidom.parse (file_or_filename)
+		#root = minidom.parse (file_or_filename)
+		root = parseUri(file_or_filename)
 		# Iterate over tracks
 		for track_node in Evaluate ("/playlist/trackList/track", root):
 			t = Track()