geo/map bugfixes
This commit is contained in:
parent
b6c74551fa
commit
dfd2787438
14 changed files with 892 additions and 809 deletions
|
|
@ -53,17 +53,14 @@ def get_countries():
|
|||
html = read_wikipedia_url('ISO 3166-3')
|
||||
matches = re.compile('<td id="([A-Z]{4})">.*?<a href="/wiki/(.*?)".*?>', re.DOTALL).findall(html)
|
||||
countries += map(lambda x: parse(x), matches)
|
||||
print sorted(map(lambda x: x['name'], countries))
|
||||
# ISO 3166-1 alpha-2
|
||||
html = fix(read_wikipedia_url('ISO 3166-1 alpha-2'))
|
||||
matches = re.compile('<tt>([A-Z]{2})</tt></td>\n<td><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
||||
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
||||
print sorted(map(lambda x: x['name'], countries))
|
||||
# List of sovereign states
|
||||
html = read_wikipedia_url('List of sovereign states')
|
||||
matches = re.compile('> </span><a href="/wiki/(.*?)"', re.DOTALL).findall(html)
|
||||
countries += filter(lambda x: not exists(x), map(lambda x: parse(x), matches))
|
||||
print sorted(map(lambda x: x['name'], countries))
|
||||
'''
|
||||
for year in range(1970, 2020, 10):
|
||||
html = read_wikipedia_url('List of sovereign states in the %ds' % year)
|
||||
|
|
@ -119,7 +116,7 @@ def get_country_data(country):
|
|||
for c, d in DATA['dependencies'].iteritems():
|
||||
c = c.split(', ')
|
||||
if name in c:
|
||||
country['dependecies'] = d if not 'dependencies' in country else country['dependencies'] + d
|
||||
country['dependencies'] = d if not 'dependencies' in country else country['dependencies'] + d
|
||||
elif name in d:
|
||||
country['dependency'] = c if not 'dependency' in country else country['dependency'] + c
|
||||
# disputes
|
||||
|
|
@ -152,10 +149,6 @@ def get_country_data(country):
|
|||
country['languages'] = [language]
|
||||
else:
|
||||
country['languages'].append(language)
|
||||
# location
|
||||
if name in DATA['location']:
|
||||
for key, value in DATA['location'][name].iteritems():
|
||||
country[key] = value
|
||||
return country
|
||||
|
||||
def get_flag(id):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import Image
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
svg_path = '../svg/icons/'
|
||||
png_path = '../png/icons/4096/'
|
||||
|
|
@ -21,16 +22,17 @@ for file in os.listdir(svg_path):
|
|||
image = image.resize((size, size), Image.ANTIALIAS)
|
||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||
|
||||
for file in os.listdir('../png/flags/'):
|
||||
if file[-4:] == '.png':
|
||||
country = file[:-4]
|
||||
png_file = png_path + country + '.png'
|
||||
print png_file
|
||||
image = Image.open(png_file)
|
||||
# include 4096 to overwrite manually generated image
|
||||
for size in [4096, 1024, 256, 64, 16]:
|
||||
image = image.resize((size, size), Image.ANTIALIAS)
|
||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||
if sys.argv[-1] == '-png':
|
||||
for file in os.listdir('../png/flags/'):
|
||||
if file[-4:] == '.png':
|
||||
country = file[:-4]
|
||||
png_file = png_path + country + '.png'
|
||||
print png_file
|
||||
image = Image.open(png_file)
|
||||
# include 4096 to overwrite manually generated image
|
||||
for size in [4096, 1024, 256, 64, 16]:
|
||||
image = image.resize((size, size), Image.ANTIALIAS)
|
||||
image.save(png_file.replace('/4096/', '/%d/' % size))
|
||||
|
||||
image = Image.new('RGB', (1152,1152))
|
||||
f = open('../json/countries.json')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue