Cddl.py revision cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0
fa9e4066f08beec538e775443c5be79dd423fcabahrensCDDL HEADER START
441d80aa4f613b6298fc8bd3151f4be02dbf84fcllingThe contents of this file are subject to the terms of the
fa9e4066f08beec538e775443c5be79dd423fcabahrensCommon Development and Distribution License (the "License").
fa9e4066f08beec538e775443c5be79dd423fcabahrensYou may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrensYou can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrensSee the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrensand limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrensWhen distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrensfile and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrensIf applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrensfields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrensinformation: Portions Copyright [yyyy] [name of copyright owner]
99653d4ee642c6528e88224f12409a5f23060994eschrockCDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens# Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens# ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens# Check source files contain a valid CDDL block
fa9e4066f08beec538e775443c5be79dd423fcabahrensCDDL = CDDL.splitlines()[1:] # Don't include initial \n
fa9e4066f08beec538e775443c5be79dd423fcabahrensCDDLStartRE = re.compile(r'^[%s ]*CDDL HEADER START' % CmntChrs)
fa9e4066f08beec538e775443c5be79dd423fcabahrensCDDLEndRE = re.compile(r'^[%s ]*CDDL HEADER END' % CmntChrs)
fa9e4066f08beec538e775443c5be79dd423fcabahrens for actual, valid in map(lambda x, y: (x and x.lstrip(CmntChrs), y),
fa9e4066f08beec538e775443c5be79dd423fcabahrensdef cddlchk(fh, filename=None, lenient=False, verbose=False, output=sys.stderr):
fa9e4066f08beec538e775443c5be79dd423fcabahrens output.write('Error: Incomplete CDDL block in file %s\n'
fa9e4066f08beec538e775443c5be79dd423fcabahrens # Check for no CDDL, warn if we're not being lenient
fa9e4066f08beec538e775443c5be79dd423fcabahrens output.write("Warning: No CDDL block in file %s\n" % filename)
fa9e4066f08beec538e775443c5be79dd423fcabahrens # Check for multiple CDDL blocks
fa9e4066f08beec538e775443c5be79dd423fcabahrens output.write('Error: Multiple CDDL blocks in file %s\n'
65cd9f2809a015b46790a9c5c2ef992d56177624eschrock for x in blocks])))
65cd9f2809a015b46790a9c5c2ef992d56177624eschrock # Validate each CDDL block
65cd9f2809a015b46790a9c5c2ef992d56177624eschrock "Error: Invalid line in CDDL block in file %s\n"
65cd9f2809a015b46790a9c5c2ef992d56177624eschrock " at line %d, should be\n"
b1b8ab34de515a5e83206da22c3d7e563241b021lling output.write("Message: Valid CDDL block in file %s\n" %