Path: blob/main/crypto/heimdal/lib/wind/rfc3454.py
34914 views
#!/usr/local/bin/python1# -*- coding: iso-8859-1 -*-23# $Id$45# Copyright (c) 2004 Kungliga Tekniska Högskolan6# (Royal Institute of Technology, Stockholm, Sweden).7# All rights reserved.8#9# Redistribution and use in source and binary forms, with or without10# modification, are permitted provided that the following conditions11# are met:12#13# 1. Redistributions of source code must retain the above copyright14# notice, this list of conditions and the following disclaimer.15#16# 2. Redistributions in binary form must reproduce the above copyright17# notice, this list of conditions and the following disclaimer in the18# documentation and/or other materials provided with the distribution.19#20# 3. Neither the name of the Institute nor the names of its contributors21# may be used to endorse or promote products derived from this software22# without specific prior written permission.23#24# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND25# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE26# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE27# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE28# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL29# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS30# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)31# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT32# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34# SUCH DAMAGE.3536import re37import string3839def read(filename):40"""return a dict of tables from rfc3454"""41f = open(filename, 'r')42inTable = False43ret = {}44while True:45l = f.readline()46if not l:47break48if inTable:49m = re.search('^ *----- End Table ([A-Z0-9\.]+) ----- *$', l)50if m:51ret[m.group(1)] = t52inTable = False53else:54t.append(l)55if re.search('^ *----- Start Table ([A-Z0-9\.]+) ----- *$', l):56inTable = True57t = []58f.close()59return ret606162