in build.py, handle locale files (overwrite constant in build version, add to json in dev version)

This commit is contained in:
rolux 2013-05-09 17:00:08 +02:00
parent 4d8c716d0b
commit 9bec02786f

View file

@ -22,6 +22,7 @@ def build_oxjs(downloads=False, geo=False):
build_path = root_path + 'build/'
dev_path = root_path + 'dev/'
locales = {}
version = '0.1.%s' % subprocess.Popen(
['bzr', 'revno'],
stdout=subprocess.PIPE
@ -116,6 +117,14 @@ def build_oxjs(downloads=False, geo=False):
link_target = target.replace(build_path, dev_path)
if not is_jquery_min:
write_link(link_source, link_target)
# locales
match = re.search('/Ox\.?(\w*?)/json/locale.(\w+).json', source)
if match:
module = match.group(1)
locale = match.group(2)
if not module in locales:
locales[module] = []
locales[module].append(locale)
# remove dangling links from dev tree that might
# be left over from renamed or removed files
for path, dirnames, filenames in os.walk(dev_path):
@ -159,12 +168,22 @@ def build_oxjs(downloads=False, geo=False):
js += read_file(source_path + js_dir + filename) + '\n'
if not js_dir + filename in sum(ox_files, []):
ox_files[-1].append(js_dir + filename)
js = re.sub("Ox.VERSION = '([\d\.]+)'", "Ox.VERSION = '%s'" % version, js)
js = re.sub(
'Ox.LOCALES = \{\}',
'Ox.LOCALES = ' + json.dumps(locales, indent=4, sort_keys=True),
js
)
js = re.sub(
"Ox.VERSION = '([\d\.]+)'",
"Ox.VERSION = '%s'" % version,
js
)
write_file(build_path + 'Ox.js', ox.js.minify(js, comment))
write_file(dev_path + '/Ox/json/' + 'Ox.json', json.dumps({
'files': ox_files,
'locales': locales,
'version': version
}, indent=4))
}, indent=4, sort_keys=True))
# Ox.UI
js = ''