21 lines
558 B
Python
21 lines
558 B
Python
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
import httplib
|
||
|
from trac.util.text import unicode_urlencode
|
||
|
from genshi import escape
|
||
|
|
||
|
try:
|
||
|
import xml.etree.ElementTree as ET
|
||
|
except:
|
||
|
try:
|
||
|
import elementtree.ElementTree as ET
|
||
|
except:
|
||
|
import celementtree.ElementTree as ET
|
||
|
|
||
|
def search_location(query):
|
||
|
conn = httplib.HTTPConnection("gazetteer.openstreetmap.org")
|
||
|
conn.request(u"GET", u"/namefinder/search.xml?%s" % unicode_urlencode({u'find': query}))
|
||
|
xmlData = conn.getresponse()
|
||
|
tree = ET.parse(xmlData)
|
||
|
return tree.findall("named")
|