2011-04-23 14:54:05 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#vim: et:ts=4:sw=4:sts=4
|
2011-04-19 09:09:51 +00:00
|
|
|
import json
|
2010-09-05 14:24:22 +00:00
|
|
|
import os
|
2011-04-22 22:03:10 +00:00
|
|
|
import re
|
2011-04-19 09:09:51 +00:00
|
|
|
|
|
|
|
def read_file(file):
|
2011-04-22 22:03:10 +00:00
|
|
|
#print 'reading', file
|
2011-04-19 09:09:51 +00:00
|
|
|
f = open(file)
|
|
|
|
data = f.read()
|
|
|
|
f.close()
|
|
|
|
return data
|
|
|
|
|
|
|
|
def write_file(file, data):
|
2011-04-22 22:03:10 +00:00
|
|
|
#print 'writing', file
|
2011-04-19 09:09:51 +00:00
|
|
|
write_path(file)
|
|
|
|
f = open(file, 'w')
|
|
|
|
f.write(data)
|
|
|
|
f.close()
|
|
|
|
return len(data)
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
def write_link(source, target):
|
|
|
|
if os.path.exists(target):
|
|
|
|
os.unlink(target)
|
|
|
|
os.symlink(source, target)
|
|
|
|
|
2011-04-19 09:09:51 +00:00
|
|
|
def write_path(file):
|
|
|
|
path = os.path.split(file)[0]
|
|
|
|
if path and not os.path.exists(path):
|
|
|
|
os.makedirs(path)
|
|
|
|
|
2011-04-23 14:54:05 +00:00
|
|
|
os.chdir(os.path.dirname(__file__))
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
source_path = '../../source/'
|
2011-04-19 09:09:51 +00:00
|
|
|
build_path = '../../build/'
|
|
|
|
|
|
|
|
# SVG
|
|
|
|
|
|
|
|
path = '../../source/svg/symbols/'
|
|
|
|
for dirname, dirnames, filenames in os.walk(path):
|
|
|
|
for filename in filenames:
|
|
|
|
if filename[0] != '.' and filename[0] != '_':
|
|
|
|
svg = read_file(path + filename)
|
|
|
|
new_filename = 'symbol' + filename[0].upper() + filename[1:]
|
|
|
|
write_file(build_path + 'svg/ox.ui.classic/' + new_filename, svg)
|
|
|
|
write_file(build_path + 'svg/ox.ui.modern/' + new_filename, svg.replace('#404040', '#FFFFFF').replace('#000000', '#FFFFFF'))
|
|
|
|
|
|
|
|
# JSON
|
2010-09-05 14:24:22 +00:00
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
files = []
|
|
|
|
|
|
|
|
for dirname, dirnames, filenames in os.walk(source_path + 'js/'):
|
|
|
|
for filename in filenames:
|
|
|
|
if filename[:1] != '.':
|
|
|
|
jquery = re.compile('jquery-[\d\.]+\.js').findall(filename)
|
|
|
|
if jquery or filename in ['Ox.js', 'OxUI.js']:
|
|
|
|
target = 'jquery.js' if jquery else filename
|
|
|
|
write_link(os.path.join(dirname, filename), build_path + 'js/' + target)
|
|
|
|
elif not '_' in dirname and not filename.endswith('.min.js'):
|
|
|
|
files.append(os.path.join(dirname.replace(source_path , '../source/'), filename))
|
2010-09-05 14:24:22 +00:00
|
|
|
|
2011-04-23 11:04:37 +00:00
|
|
|
for dirname, dirnames, filenames in os.walk(source_path + 'css'):
|
|
|
|
for filename in filenames:
|
|
|
|
if filename[:1] != '.':
|
|
|
|
write_link(os.path.join(dirname, filename), build_path + 'css/' + filename)
|
|
|
|
|
2011-04-19 09:09:51 +00:00
|
|
|
for dirname, dirnames, filenames in os.walk(build_path + 'png'):
|
|
|
|
for filename in filenames:
|
|
|
|
if filename[:1] != '.':
|
2011-04-22 22:03:10 +00:00
|
|
|
files.append(os.path.join(dirname.replace(build_path, ''), filename))
|
2011-04-19 09:09:51 +00:00
|
|
|
|
|
|
|
for dirname, dirnames, filenames in os.walk(build_path + 'svg'):
|
2010-09-05 14:24:22 +00:00
|
|
|
for filename in filenames:
|
|
|
|
if filename[:1] != '.':
|
2011-04-22 22:03:10 +00:00
|
|
|
files.append(os.path.join(dirname.replace(build_path, ''), filename))
|
2010-09-05 14:24:22 +00:00
|
|
|
|
2011-04-23 14:54:05 +00:00
|
|
|
write_file(build_path + 'json/OxUI.json', json.dumps(files, indent=4, sort_keys=True))
|