<s> import cStringIO <EOL> import struct <EOL> import dns . exception <EOL> import dns . rdata <EOL> class NSEC3PARAM ( dns . rdata . Rdata ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , rdclass , rdtype , algorithm , flags , iterations , salt ) : <EOL> super ( NSEC3PARAM , self ) . __init__ ( rdclass , rdtype ) <EOL> self . algorithm = algorithm <EOL> self . flags = flags <EOL> self . iterations = iterations <EOL> self . salt = salt <EOL> def to_text ( self , origin = None , relativize = True , ** kw ) : <EOL> if self . salt == '<STR_LIT>' : <EOL> salt = '<STR_LIT:->' <EOL> else : <EOL> salt = self . salt . encode ( '<STR_LIT>' ) <EOL> return '<STR_LIT>' % ( self . algorithm , self . flags , self . iterations , salt ) <EOL> def from_text ( cls , rdclass , rdtype , tok , origin = None , relativize = True ) : <EOL> algorithm = tok . get_uint8 ( ) <EOL> flags = tok . get_uint8 ( ) <EOL> iterations = tok . get_uint16 ( ) <EOL> salt = tok . get_string ( ) <EOL> if salt == '<STR_LIT:->' : <EOL> salt = '<STR_LIT>' <EOL> else : <EOL> salt = salt . decode ( '<STR_LIT>' ) <EOL> tok . get_eol ( ) <EOL> return cls ( rdclass , rdtype , algorithm , flags , iterations , salt ) <EOL> from_text = classmethod ( from_text ) <EOL> def to_wire ( self , file , compress = None , origin = None ) : <EOL> l = len ( self . salt ) <EOL> file . write ( struct . pack ( "<STR_LIT>" , self . algorithm , self . flags , <EOL> self . iterations , l ) ) <EOL> file . write ( self . salt ) <EOL> def from_wire ( cls , rdclass , rdtype , wire , current , rdlen , origin = None ) : <EOL> ( algorithm , flags , iterations , slen ) = struct . unpack ( '<STR_LIT>' , <EOL> wire [ current : current + <NUM_LIT:5> ] ) <EOL> current += <NUM_LIT:5> <EOL> rdlen -= <NUM_LIT:5> <EOL> salt = wire [ current : current + slen ] . unwrap ( ) <EOL> current += slen <EOL> rdlen -= slen <EOL> if rdlen != <NUM_LIT:0> : <EOL> raise dns . exception . FormError <EOL> return cls ( rdclass , rdtype , algorithm , flags , iterations , salt ) <EOL> from_wire = classmethod ( from_wire ) </s>
