Skip to content

Instantly share code, notes, and snippets.

@flodolo
Created June 10, 2015 11:24
Show Gist options
  • Save flodolo/575245a97054e99b41e0 to your computer and use it in GitHub Desktop.
Save flodolo/575245a97054e99b41e0 to your computer and use it in GitHub Desktop.
Check lang file group of tags
#! /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