#NEWLINE# def decode( self , taglist ) : #NEWLINE# #INDENT# if _debug : #NEWLINE# #INDENT# Sequence . _debug ( 'decode %r' , taglist ) #NEWLINE# #UNINDENT# if ( not isinstance ( taglist , TagList ) ) : #NEWLINE# #INDENT# raise TypeError ( 'TagList expected' ) #NEWLINE# #UNINDENT# for element in self . sequenceElements : #NEWLINE# #INDENT# tag = taglist . Peek ( ) #NEWLINE# if ( tag is None ) : #NEWLINE# #INDENT# if element . optional : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( element . klass in _sequence_of_classes ) : #NEWLINE# #INDENT# setattr ( self , element . name , [ ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise AttributeError ( ( "'%s' is a required element of %s" % ( element . name , self . __class__ . __name__ ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag . tagClass == Tag . closingTagClass ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise AttributeError ( ( "'%s' is a required element of %s" % ( element . name , self . __class__ . __name__ ) ) ) #NEWLINE# #UNINDENT# setattr ( self , element . name , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( element . klass in _sequence_of_classes ) : #NEWLINE# #INDENT# if ( element . context is not None ) : #NEWLINE# #INDENT# if ( ( tag . tagClass != Tag . openingTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected opening tag %d" % ( element . name , element . context ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , [ ] ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# taglist . Pop ( ) #NEWLINE# #UNINDENT# helper = element . klass ( ) #NEWLINE# helper . decode ( taglist ) #NEWLINE# setattr ( self , element . name , helper . value ) #NEWLINE# if ( element . context is not None ) : #NEWLINE# #INDENT# tag = taglist . Pop ( ) #NEWLINE# if ( ( tag . tagClass != Tag . closingTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected closing tag %d" % ( element . name , element . context ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( element . klass , Atomic ) : #NEWLINE# #INDENT# if ( element . context is not None ) : #NEWLINE# #INDENT# if ( ( tag . tagClass != Tag . contextTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected context tag %d" % ( element . name , element . context ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# tag = tag . context_to_app ( element . klass . _app_tag ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( tag . tagClass != Tag . applicationTagClass ) or ( tag . tagNumber != element . klass . _app_tag ) ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected application tag %s" % ( element . name , Tag . _app_tag_name [ element . klass . _app_tag ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# taglist . Pop ( ) #NEWLINE# helper = element . klass ( tag ) #NEWLINE# setattr ( self , element . name , helper . value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( element . klass , AnyAtomic ) : #NEWLINE# #INDENT# if ( element . context is not None ) : #NEWLINE# #INDENT# if ( ( tag . tagClass != Tag . contextTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected context tag %d" % ( element . name , element . context ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# tag = tag . context_to_app ( element . klass . _app_tag ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag . tagClass != Tag . applicationTagClass ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected application tag" % ( element . name , ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# taglist . Pop ( ) #NEWLINE# helper = element . klass ( tag ) #NEWLINE# setattr ( self , element . name , helper . value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( element . context is not None ) : #NEWLINE# #INDENT# if ( ( tag . tagClass != Tag . openingTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# if ( not element . optional ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected opening tag %d" % ( element . name , element . context ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# taglist . Pop ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# backup = taglist . tagList [ : ] #NEWLINE# value = element . klass ( ) #NEWLINE# value . decode ( taglist ) #NEWLINE# setattr ( self , element . name , value ) #NEWLINE# #UNINDENT# except DecodingError : #NEWLINE# #INDENT# if ( ( element . context is None ) and element . optional ) : #NEWLINE# #INDENT# setattr ( self , element . name , None ) #NEWLINE# taglist . tagList = backup #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# if ( element . context is not None ) : #NEWLINE# #INDENT# tag = taglist . Pop ( ) #NEWLINE# if ( ( not tag ) or ( tag . tagClass != Tag . closingTagClass ) or ( tag . tagNumber != element . context ) ) : #NEWLINE# #INDENT# raise DecodingError ( ( "'%s' expected closing tag %d" % ( element . name , element . context ) ) )