1*ebfedea0SLionel Sambuc#!/usr/local/bin/python 2*ebfedea0SLionel Sambuc# -*- coding: iso-8859-1 -*- 3*ebfedea0SLionel Sambuc 4*ebfedea0SLionel Sambuc# Id 5*ebfedea0SLionel Sambuc 6*ebfedea0SLionel Sambuc# Copyright (c) 2008 Kungliga Tekniska Högskolan 7*ebfedea0SLionel Sambuc# (Royal Institute of Technology, Stockholm, Sweden). 8*ebfedea0SLionel Sambuc# All rights reserved. 9*ebfedea0SLionel Sambuc# 10*ebfedea0SLionel Sambuc# Redistribution and use in source and binary forms, with or without 11*ebfedea0SLionel Sambuc# modification, are permitted provided that the following conditions 12*ebfedea0SLionel Sambuc# are met: 13*ebfedea0SLionel Sambuc# 14*ebfedea0SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 15*ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer. 16*ebfedea0SLionel Sambuc# 17*ebfedea0SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 18*ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 19*ebfedea0SLionel Sambuc# documentation and/or other materials provided with the distribution. 20*ebfedea0SLionel Sambuc# 21*ebfedea0SLionel Sambuc# 3. Neither the name of the Institute nor the names of its contributors 22*ebfedea0SLionel Sambuc# may be used to endorse or promote products derived from this software 23*ebfedea0SLionel Sambuc# without specific prior written permission. 24*ebfedea0SLionel Sambuc# 25*ebfedea0SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 26*ebfedea0SLionel Sambuc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27*ebfedea0SLionel Sambuc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28*ebfedea0SLionel Sambuc# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 29*ebfedea0SLionel Sambuc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30*ebfedea0SLionel Sambuc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31*ebfedea0SLionel Sambuc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32*ebfedea0SLionel Sambuc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33*ebfedea0SLionel Sambuc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34*ebfedea0SLionel Sambuc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35*ebfedea0SLionel Sambuc# SUCH DAMAGE. 36*ebfedea0SLionel Sambuc 37*ebfedea0SLionel Sambucimport re 38*ebfedea0SLionel Sambucimport string 39*ebfedea0SLionel Sambuc 40*ebfedea0SLionel Sambucdef _merge_table(res, source): 41*ebfedea0SLionel Sambuc for table in source.keys(): 42*ebfedea0SLionel Sambuc res[table] = res.get(table, []) + source.get(table, []) 43*ebfedea0SLionel Sambuc 44*ebfedea0SLionel Sambucname_error = ['C.1.2', 'C.2.2', 'C.3', 'C.4', 'C.5', 'C.6', 'C.7', 'C.8', 'C.9'] 45*ebfedea0SLionel Sambucldap_error = ['A.1', 'C.3', 'C.4', 'C.5', 'C.8', 'rfc4518-error' ] 46*ebfedea0SLionel Sambucsasl_error = ['C.1.2', 'C.2.1', 'C.2.2', 'C.3', 'C.4', 'C.5', 'C.6', 'C.7', 'C.8', 'C.9'] 47*ebfedea0SLionel Sambuc 48*ebfedea0SLionel Sambucname_map = ['B.1', 'B.2'] 49*ebfedea0SLionel Sambucldap_map = ['rfc4518-map'] 50*ebfedea0SLionel Sambucldap_case_map = ['rfc4518-map', 'B.2'] 51*ebfedea0SLionel Sambucsasl_map = ['C.1.2', 'B.1'] 52*ebfedea0SLionel Sambuc 53*ebfedea0SLionel Sambucdef symbols(tabledict, tables): 54*ebfedea0SLionel Sambuc """return CPP symbols to use for this symbols""" 55*ebfedea0SLionel Sambuc list = [] 56*ebfedea0SLionel Sambuc for x in tables: 57*ebfedea0SLionel Sambuc list = list + tabledict.get(x, []) 58*ebfedea0SLionel Sambuc if len(list) == 0: 59*ebfedea0SLionel Sambuc return "" 60*ebfedea0SLionel Sambuc return "|".join(map(lambda x: "WIND_PROFILE_%s" % (string.upper(x)), list)) 61*ebfedea0SLionel Sambuc 62*ebfedea0SLionel Sambucdef get_errorlist(): 63*ebfedea0SLionel Sambuc d = dict() 64*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['name']], name_error))) 65*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['ldap']], ldap_error))) 66*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['sasl']], sasl_error))) 67*ebfedea0SLionel Sambuc return d 68*ebfedea0SLionel Sambuc 69*ebfedea0SLionel Sambucdef get_maplist(): 70*ebfedea0SLionel Sambuc d = dict() 71*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['name']], name_map))) 72*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['ldap']], ldap_map))) 73*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['ldap_case']], ldap_case_map))) 74*ebfedea0SLionel Sambuc _merge_table(d, dict(map(lambda x: [x, ['sasl']], sasl_map))) 75*ebfedea0SLionel Sambuc return d 76*ebfedea0SLionel Sambuc 77*ebfedea0SLionel Sambucdef sort_merge_trans(trans): 78*ebfedea0SLionel Sambuc trans.sort() 79*ebfedea0SLionel Sambuc ret = [] 80*ebfedea0SLionel Sambuc last = 0 81*ebfedea0SLionel Sambuc for x in trans: 82*ebfedea0SLionel Sambuc if last: 83*ebfedea0SLionel Sambuc if last[0] == x[0]: 84*ebfedea0SLionel Sambuc last = (last[0], last[1], last[2], last[3] + x[3]) 85*ebfedea0SLionel Sambuc else: 86*ebfedea0SLionel Sambuc ret.append(last) 87*ebfedea0SLionel Sambuc last = x 88*ebfedea0SLionel Sambuc else: 89*ebfedea0SLionel Sambuc last = x 90*ebfedea0SLionel Sambuc if last: 91*ebfedea0SLionel Sambuc ret.append(last) 92*ebfedea0SLionel Sambuc return ret 93