update geo tools

This commit is contained in:
rolux 2013-08-01 12:16:20 +02:00
parent 4a635c4038
commit b689a4013b

View file

@ -38,6 +38,8 @@ def encode_wikipedia_id(id):
return id.replace(' ', '_').encode('utf8')
def get_countries():
def exclude(country):
return country['name'] in ['Federation of Bosnia and Herzegovina', 'Republika Srpska']
def exists(country):
for c in countries:
if c['name'] == country['name']:
@ -74,7 +76,7 @@ def get_countries():
# List of sovereign states
html = read_wikipedia_url('List of sovereign states')
matches = re.compile('>&#160;</span><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
countries += filter(lambda x: not exists(x) and not exclude(x) , map(lambda x: parse(x), matches))
'''
for year in range(1970, 2020, 10):
html = read_wikipedia_url('List of sovereign states in the %ds' % year)