#!/usr/bin/python # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import re import sys try: utilsfh = open('utils.php', 'r') except: print("utils.php not found. This script needs to be run from the directory containing utils.php") sys.exit(1) for line in utilsfh: if line == '\t# START DOJO PARSING\n': break mode = 'findname' sections = [] for line in utilsfh: line = line.strip() if line == '# END DOJO PARSING': break if mode == 'findname' and re.search('filename = ', line): tmp = line.split(' ') tmp = tmp[2] tmp = line.split("'"); filename = tmp[1] section = "\t\t{\n" section += '\t\t\tname: "%s",\n' % filename mode = 'findobjects' elif mode == 'findobjects' and re.search('dojoRequires = .*\);$', line): mode = 'addobjects' tmp = line.split('(') tmp = tmp[1].split(')') obj = tmp[0] objs = [] objs.append("\t\t\t\t%s" % obj) elif mode == 'findobjects' and re.search('dojoRequires = ', line): mode = 'addobjects' tmp = line.split('(') obj = tmp[1] objs = [] objs.append("\t\t\t\t%s" % obj) elif mode == 'addobjects' and re.search('^break;$', line): mode = 'findname' section += '\t\t\tdependencies: [\n' section += '\n'.join(objs) section += '\n\t\t\t]\n' sections.append(section) elif mode == 'addobjects' and re.search('\);$', line): tmp = line.split(')') objs.append("\t\t\t\t%s" % tmp[0]) elif mode == 'addobjects': objs.append("\t\t\t\t%s" % line) utilsfh.close() dojofh = open('vcl.profile.js', 'w') dojofh.write('dependencies = {\n') dojofh.write('\tlayers: [\n') dojofh.write(' },\n'.join(sections)) dojofh.write(' }\n') dojofh.write('\t],\n') dojofh.write('\tprefixes: [\n') dojofh.write('\t\t["dijit", "../dijit"],\n') #dojofh.write('\t\t["dojo", "../../dojo"],\n') dojofh.write('\t\t["dojox", "../dojox"],\n') dojofh.write('\t\t["vcldojo", "../vcldojo", "../../release/dojo/vcldojo/al2licenseheader.txt"]\n') dojofh.write('\t]\n') dojofh.write('};\n') dojofh.close()