[Commits] python.it commit r249 - code/pythonisti/trunk/pythonisti/geo

commit a svn.python.it commit a svn.python.it
Sab 30 Dic 2006 22:59:45 CET


Author: manlio
Date: Sat Dec 30 22:59:45 2006
New Revision: 249

Modified:
   code/pythonisti/trunk/pythonisti/geo/google.py
Log:
Corretta la gestione indirizzi del Geocoder di Google.
Ora viene controllato che l'indirizzo trovato sia unico.


Modified: code/pythonisti/trunk/pythonisti/geo/google.py
==============================================================================
--- code/pythonisti/trunk/pythonisti/geo/google.py	(original)
+++ code/pythonisti/trunk/pythonisti/geo/google.py	Sat Dec 30 22:59:45 2006
@@ -17,6 +17,8 @@
 class AddressNotFound(Exception):
     pass
 
+class MultipleAddress(Exception):
+    pass
 
 
 def get_page(url):
@@ -62,4 +64,10 @@
     if status['code'] != 200:
         raise AddressNotFound()
 
-    return response['Placemark'][0]
+    r = response['Placemark']
+    if len(r) > 1:
+        # TODO for now we raise an exception
+        address_list = [item['address'] for item in r]
+        raise MultipleAddress(address_list)
+
+    return r[0]


Maggiori informazioni sulla lista Commits