annotate urlFunctions.py @ 266:c37e8c173136

Multilayer for Europeana4D
author fknauft
date Wed, 25 Jan 2012 20:43:05 +0100
parents 47bba001d718
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
247
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
1 import xml.dom.minidom
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
2 #from xml.dom import utils
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
3 from xml.dom.minidom import parseString
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
4 import urllib
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
5
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
6 def zUrlopenRead(self,url):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
7 return urllib.urlopen(url).read()
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
8
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
9 def zUrlopenInfo(self,url):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
10 return urllib.urlopen(url).info()
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
11
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
12 def zUrlopenParseString(self,string):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
13 return parseString(string)
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
14
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
15 def zUrlopenDocumentElement(self,doc):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
16 return doc.documentElement
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
17
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
18 def zUrlopenChildNodes(self,docnode):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
19 return docnode.childNodes
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
20
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
21 def zUrlopenGetElementsByTagName(self,docnodelist,name):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
22 return docnodelist.getElementsByTagName(name)
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
23
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
24 def zUrlopenLength(self,docnodelist):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
25 return docnodelist.length
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
26
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
27 def zUrlopenGetItem(self,docnodelist,number):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
28 return docnodelist.item(number)
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
29
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
30 def zUrlopenGetAttribute(self,docnode,name):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
31 return docnode.getAttribute(name)
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
32
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
33 def zUrlopenGetTextData(self,docnode):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
34 # return docnode.nodeName
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
35 return getText(docnode.childNodes)
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
36
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
37 def getText(nodelist):
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
38 rc = ""
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
39 for node in nodelist:
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
40 if node.nodeType == node.TEXT_NODE:
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
41 rc = rc + node.data
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
42 return rc
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
43
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
44
47bba001d718 show line and polygon-layer
fknauft
parents:
diff changeset
45