annotate tools/flag_data.py @ 693:ad69236e8501
For issue #52, update many 3rd party Javascript libraries.
Updated to jquery 1.10.2, jquery ui 1.10.3.
This broke a lot of stuff.
- Found a newer version of the jquery cycle all plugin (3.0.3).
- Updated JPlayer to 2.4.0.
- Updated to MarkItUp 1.1.14. This also required me to add multiline attributes
set to true on various buttons in the markdown set.
- As per a stackoverflow post, added some code to get multiline titles in
a jQuery UI dialog. They removed that functionality but allow you to put it
back.
Tweaked the MarkItUp preview CSS to show blockquotes in italic.
Did not update TinyMCE at this time. I'm not using the JQuery version and this
version appears to work ok for now.
What I should do is make a repo for MarkItUp and do a vendor branch thing so
I don't have to futz around diffing directories to figure out if I'll lose
changes when I update.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 04 Sep 2013 19:55:20 -0500 |
parents |
678a1a2ef55a |
children |
|
rev |
line source |
bgneal@607
|
1 """
|
bgneal@607
|
2 Application to read the ISO-3166 country data and output a JSON datastructure
|
bgneal@607
|
3 for use in the SG101 code. We also print a report of any missing country
|
bgneal@607
|
4 icons. If we don't have an icon for a country, we don't include it in our JSON
|
bgneal@607
|
5 data.
|
bgneal@607
|
6
|
bgneal@607
|
7 """
|
bgneal@607
|
8 import argparse
|
bgneal@607
|
9 import json
|
bgneal@607
|
10 import os.path
|
bgneal@609
|
11 import sys
|
bgneal@607
|
12 from xml.etree.ElementTree import ElementTree
|
bgneal@607
|
13
|
bgneal@607
|
14
|
bgneal@607
|
15 def main():
|
bgneal@607
|
16 parser = argparse.ArgumentParser(description=("Transform Debian's ISO-3166 "
|
bgneal@607
|
17 "data into JSON for use on SG101"))
|
bgneal@607
|
18 parser.add_argument('--xml', '-x', required=True, help='path to XML file')
|
bgneal@607
|
19 parser.add_argument('--icon-dir', '-i', required=True,
|
bgneal@607
|
20 help='path to icon directory')
|
bgneal@607
|
21
|
bgneal@607
|
22 args = parser.parse_args()
|
bgneal@607
|
23
|
bgneal@607
|
24 xml_file = os.path.expanduser(args.xml)
|
bgneal@607
|
25 icon_dir = os.path.expanduser(args.icon_dir)
|
bgneal@607
|
26
|
bgneal@607
|
27 with open(xml_file, 'r') as fp:
|
bgneal@607
|
28 et = ElementTree(file=fp)
|
bgneal@607
|
29
|
bgneal@607
|
30 country_data = {}
|
bgneal@607
|
31 for node in et.iterfind('iso_3166_entry'):
|
bgneal@607
|
32 code = node.get('alpha_2_code').lower()
|
bgneal@607
|
33 name = node.get('common_name', node.get('name'))
|
bgneal@607
|
34
|
bgneal@607
|
35 # see if we have an icon for this country
|
bgneal@607
|
36
|
bgneal@607
|
37 if not os.path.exists(os.path.join(icon_dir, '%s.png' % code)):
|
bgneal@609
|
38 sys.stderr.write("Could not find icon for %s (%s)\n" % (name, code))
|
bgneal@607
|
39 else:
|
bgneal@607
|
40 country_data[code] = name
|
bgneal@607
|
41
|
bgneal@607
|
42 s = json.dumps(country_data, indent=4, sort_keys=True, ensure_ascii=False)
|
bgneal@607
|
43 print s.encode('utf-8')
|
bgneal@607
|
44
|
bgneal@607
|
45
|
bgneal@607
|
46 if __name__ == '__main__':
|
bgneal@607
|
47 main()
|