[gnome-clocks] Import world clocks in the old format



commit f96121496e2497a944eb2c4312619731b362095e
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 2 21:38:17 2012 +0100

    Import world clocks in the old format

 gnomeclocks/world.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index b5517c4..d0b29bc 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -49,8 +49,16 @@ class WorldClockStorage:
             locations = json.load(f)
             f.close()
             for l in locations:
-                variant = GLib.Variant.parse(None, l, None, None)
-                location = GWeather.Location.deserialize(gweather_world, variant)
+                try:
+                    variant = GLib.Variant.parse(None, l, None, None)
+                    location = GWeather.Location.deserialize(gweather_world, variant)
+                except:
+                    location = None
+                if not location:
+                    # This is for backward compatibility importing the old clocks which
+                    # just saved the metar location code... for now we may end up here
+                    # both if deserialize fails of if variant parse throws an exception
+                    location = GWeather.Location.find_by_station_code(gweather_world, l)
                 if location:
                     clock = ClockItem(location)
                     clocks.append(clock)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]