Skip to content

Instantly share code, notes, and snippets.

@flodolo
Last active August 10, 2016 11:12
Show Gist options
  • Save flodolo/b8e891379c9cbb9c0e8d7bcaec3aa416 to your computer and use it in GitHub Desktop.
Save flodolo/b8e891379c9cbb9c0e8d7bcaec3aa416 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import urllib2
import sys
def diff(a, b):
b = set(b)
return [aa for aa in a if aa not in b]
def main():
update_sources = {
'aurora' : {
'sources': [
'http://hg.mozilla.org/releases/mozilla-aurora/raw-file/default/browser/locales/all-locales',
'http://hg.mozilla.org/releases/mozilla-aurora/raw-file/default/mobile/android/locales/all-locales',
]
},
}
for id, update_source in update_sources.iteritems():
supported_locales = []
for url in update_source['sources']:
print 'Reading sources for {0} from {1}'.format(id, url)
response = urllib2.urlopen(url)
for locale in response:
locale = locale.replace('\n', '')
if locale != '' and locale not in supported_locales:
supported_locales.append(locale)
# Sort locales
supported_locales.sort()
# Compare with online version
compare_url = 'https://raw.githubusercontent.com/mozilla-releng/ship-it/master/kickoff/config.py'
response = urllib2.urlopen(compare_url)
file_content = response.read()
with open ('shipit_settings.py', 'wb') as f:
f.write(file_content)
import shipit_settings
print "\nMissing locales:"
print '\n'.join(diff(supported_locales, shipit_settings.SUPPORTED_AURORA_LOCALES))
print "\nExtra locales:"
print '\n'.join(diff(shipit_settings.SUPPORTED_AURORA_LOCALES, supported_locales))
# Remove downloaded settings file
os.remove('shipit_settings.py')
os.remove('shipit_settings.pyc')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment