diff options
author | Dan Winship <danw@src.gnome.org> | 2008-11-25 18:39:18 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2008-11-25 18:39:18 +0000 |
commit | 3dd86ed79b065003eec34daa1112cb96dff8c0dd (patch) | |
tree | 933ca846830d58821adc03798415b215a1435e1c /data/update-locations.py | |
parent | ed1306f2e2186d3b0670b21fba84068cad896aa6 (diff) | |
download | libgweather-3dd86ed79b065003eec34daa1112cb96dff8c0dd.tar.gz |
Don't worry about sub-city locations; people generally aren't
going to know which of the locations is closest to them, and the
weather reports from all of them should be basically the same
anyway.
* data/update-locations.py (Location.print_xml): never use <_name>
for location-level names; always just use <name> so they don't get
localized
(observations_url): add a hack to let you override the
recent-observations file, so you can regenerate Locations.xml.in
without changing the set of active stations
(Country.__init__): add "Bahamas" to the list of countries whose
name we put "the" before in comments
* data/Locations.xml.in: regen, dropping localization for
<location> nodes
* libgweather/gweather-xml.c (gweather_xml_parse_node): Remove the
cities-with-multiple-locations code, and just make all cities use
their first child location. Also, ignore <location>s that aren't
children of <city>s (which should be impossible now anyway).
* libgweather/location-entry.c (fill_location_entry_model):
likewise
svn path=/trunk/; revision=518
Diffstat (limited to 'data/update-locations.py')
-rw-r--r-- | data/update-locations.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/data/update-locations.py b/data/update-locations.py index 01a70b6..ca68802 100644 --- a/data/update-locations.py +++ b/data/update-locations.py @@ -4,6 +4,7 @@ import codecs import locale import math +import os import re import sqlite3 import sys @@ -245,7 +246,7 @@ class Country(LocBase): self.name.find('Republic') != -1 or \ self.name.find('lands') != -1: self.in_name = 'the ' + self.name - elif re.search(r'(IM|MV|PH|PS|SC|TF|VA)', self.iso_code): + elif re.search(r'(BS|IM|MV|PH|PS|SC|TF|VA)', self.iso_code): self.in_name = 'the ' + self.name else: self.in_name = self.name @@ -346,7 +347,7 @@ class City(LocBase): print '%s <_name>%s</_name>' % (indent, saxutils.escape(self.name)) print '%s <coordinates>%s</coordinates>' % (indent, self.coordinates) for item in self.contents: - item.print_xml(indent + ' ', self, len(self.contents) > 1) + item.print_xml(indent + ' ', self) print '%s</city>' % indent class Location(LocBase): @@ -365,7 +366,7 @@ class Location(LocBase): if self.code in station_comments: self.comment = station_comments[self.code] - def print_xml(self, indent, city=None, localize=True): + def print_xml(self, indent, city=None): print '%s<location>' % indent name = self.name if city is not None: @@ -379,10 +380,7 @@ class Location(LocBase): name = name[:-len(city.name) - 2] #if self.comment is not None: # print '%s <!-- %s -->' % (indent, self.comment) - if localize: - print '%s <_name>%s</_name>' % (indent, saxutils.escape(name)) - else: - print '%s <name>%s</name>' % (indent, saxutils.escape(name)) + print '%s <name>%s</name>' % (indent, saxutils.escape(name)) print '%s <code>%s</code>' % (indent, self.code) LocBase.print_xml(self, indent) print '%s</location>' % indent @@ -625,7 +623,8 @@ def find_city(c, city_name, station, try_nearby): return city -observations = urllib.urlopen('http://gnome.org/~danw/observations.txt') +observations_url = os.getenv('OBSERVATIONS_URL') or 'http://gnome.org/~danw/observations.txt' +observations = urllib.urlopen(observations_url) recent = [obs.rstrip() for obs in observations.readlines()] observations.close() |