annotate tools/tz.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 ed6202fb08b6
children
rev   line source
bgneal@245 1 """
bgneal@245 2 This program generates the data used by the timezone.js Javascript.
bgneal@245 3 This data is used to create the 2 dropdown select boxes for timezones.
bgneal@245 4 """
bgneal@245 5 import pytz
bgneal@245 6 from pprint import pprint
bgneal@245 7
bgneal@245 8 def format_locations(locs):
bgneal@245 9 ss = ["[%s]" % ", ".join(["'%s'" % l for l in loc]) for loc in locs]
bgneal@245 10 return "%s" % ",\n".join(ss)
bgneal@245 11
bgneal@245 12 # get a list of areas
bgneal@245 13
bgneal@245 14 zones = [z.split('/') for z in pytz.common_timezones]
bgneal@245 15 areas = set([zone[0] for zone in zones if len(zone) > 1])
bgneal@245 16 areas = list(areas)
bgneal@245 17 areas.sort()
bgneal@245 18
bgneal@245 19 locations = dict([(area, []) for area in areas])
bgneal@245 20
bgneal@245 21 #pprint(locations)
bgneal@245 22
bgneal@245 23 for zone in pytz.common_timezones:
bgneal@245 24 if zone.count('/') == 0:
bgneal@245 25 continue
bgneal@245 26 area, loc = zone.split('/', 1)
bgneal@245 27 if area in locations:
bgneal@245 28 locations[area].append(loc.replace('_', ' '))
bgneal@245 29
bgneal@245 30 #pprint(locations)
bgneal@245 31
bgneal@245 32 for area in locations.iterkeys():
bgneal@245 33 locations[area].sort()
bgneal@245 34
bgneal@245 35 locs = []
bgneal@245 36 for area in areas:
bgneal@245 37 locs.append(locations[area])
bgneal@245 38
bgneal@245 39 #pprint(locs)
bgneal@245 40
bgneal@245 41 default_area = areas.index('US')
bgneal@245 42 default_location = locs[default_area].index('Pacific')
bgneal@245 43
bgneal@245 44 print """\
bgneal@245 45 var gcalTzInfo = {
bgneal@245 46 areas: [%s],
bgneal@245 47 locations: [%s],
bgneal@245 48 default_area: %s,
bgneal@245 49 default_location: %s
bgneal@245 50 };
bgneal@245 51 """ % (", ".join(["'%s'" % area for area in areas]),
bgneal@245 52 format_locations(locs),
bgneal@245 53 default_area,
bgneal@245 54 default_location,
bgneal@245 55 )