Created
June 10, 2015 11:24
-
-
Save flodolo/575245a97054e99b41e0 to your computer and use it in GitHub Desktop.
Check lang file group of tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import json | |
import urllib2 | |
# URL to extract activated pages from langchecker's json | |
filename = 'mozorg/plugincheck.lang' | |
api_url = 'http://l10n.mozilla-community.org/~pascalc/langchecker/?locale=all&website=0&json&file=' + filename | |
try: | |
response = urllib2.urlopen(api_url) | |
json_data = json.load(response) | |
tag_groups = {} | |
for locale in json_data[filename]: | |
if json_data[filename][locale]['activated']: | |
tags = json_data[filename][locale]['tags'] | |
group_name = '+'.join(tags) | |
if group_name in tag_groups: | |
tag_groups[group_name].append(locale) | |
else: | |
tag_groups[group_name] = [locale] | |
for group in tag_groups: | |
tag_groups[group].sort() | |
print json.dumps(tag_groups, sort_keys=True, indent=4) | |
except Exception as e: | |
print 'Error reading json file from ' + api_url | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment