diff options
author | emkael <emkael@tlen.pl> | 2016-05-10 12:14:37 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-10 12:14:37 +0200 |
commit | 9f5d4fc0939c6dad4d341df9e85623be31449444 (patch) | |
tree | 4b9fb52ae1923b923610119359a184bbd9bfdbf2 /app | |
parent | 7dd9e6b84354c12a3772db81dc5139665275d79b (diff) |
* first day of the week per territory imported to configuration
Diffstat (limited to 'app')
-rw-r--r-- | app/python/weekdays.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/python/weekdays.py b/app/python/weekdays.py new file mode 100644 index 0000000..547f6b2 --- /dev/null +++ b/app/python/weekdays.py @@ -0,0 +1,32 @@ +import json +import os +import urllib + +from lxml import etree + + +def main(): + week_day_config = {} + + supplemental_data = etree.fromstring( + urllib.urlopen( + 'http://unicode.org/repos/cldr/trunk/common/supplemental/' + + 'supplementalData.xml' + ).read()) + for first_day in supplemental_data.xpath('weekData/firstDay[not(@alt)]'): + day = first_day.get('day') + territories = first_day.get('territories').split() + for territory in territories: + week_day_config[territory] = day + + json.dump(week_day_config, + file(os.path.join( + os.environ['PYTHONPATH'], + 'config', + 'weekdays.json'), 'w'), + sort_keys=True, + indent=4, + separators=(',', ': ')) + +if __name__ == '__main__': + main() |