File dnscompr.py of Package dhcp

#!/usr/bin/python

# Copyright 2005 Peter Poeml <poeml@suse.de>. All Rights Reserved.
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.


def compr(names):
	import dns, dns.name, cStringIO

        f = cStringIO.StringIO()
        compress = {}

	for i in names:
		n = dns.name.from_text(i)
		n.to_wire(f, compress)


	return f.getvalue()

if __name__ == '__main__':
	import sys
	nlist = sys.argv[1:]
	print repr(compr(nlist))