Mercurial > public > sg101
comparison tools/flag_data.py @ 609:678a1a2ef55a
For issue 16, add country flag icons to user profiles & forum posts.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 28 Jul 2012 15:12:09 -0500 |
parents | 34b1dd3f84fa |
children |
comparison
equal
deleted
inserted
replaced
608:8ddd6490cbc9 | 609:678a1a2ef55a |
---|---|
6 | 6 |
7 """ | 7 """ |
8 import argparse | 8 import argparse |
9 import json | 9 import json |
10 import os.path | 10 import os.path |
11 import sys | |
11 from xml.etree.ElementTree import ElementTree | 12 from xml.etree.ElementTree import ElementTree |
12 | 13 |
13 | 14 |
14 def main(): | 15 def main(): |
15 parser = argparse.ArgumentParser(description=("Transform Debian's ISO-3166 " | 16 parser = argparse.ArgumentParser(description=("Transform Debian's ISO-3166 " |
32 name = node.get('common_name', node.get('name')) | 33 name = node.get('common_name', node.get('name')) |
33 | 34 |
34 # see if we have an icon for this country | 35 # see if we have an icon for this country |
35 | 36 |
36 if not os.path.exists(os.path.join(icon_dir, '%s.png' % code)): | 37 if not os.path.exists(os.path.join(icon_dir, '%s.png' % code)): |
37 print "Could not find icon for %s (%s)" % (name, code) | 38 sys.stderr.write("Could not find icon for %s (%s)\n" % (name, code)) |
38 else: | 39 else: |
39 country_data[code] = name | 40 country_data[code] = name |
40 | 41 |
41 s = json.dumps(country_data, indent=4, sort_keys=True, ensure_ascii=False) | 42 s = json.dumps(country_data, indent=4, sort_keys=True, ensure_ascii=False) |
42 print s.encode('utf-8') | 43 print s.encode('utf-8') |