<s> """<STR_LIT>""" <EOL> import base <EOL> class Behavior ( object ) : <EOL> """<STR_LIT>""" <EOL> name = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> versionString = '<STR_LIT>' <EOL> knownChildren = { } <EOL> quotedPrintable = False <EOL> defaultBehavior = None <EOL> hasNative = False <EOL> isComponent = False <EOL> allowGroup = False <EOL> forceUTC = False <EOL> sortFirst = [ ] <EOL> def __init__ ( self ) : <EOL> err = "<STR_LIT>" <EOL> raise base . VObjectError ( err ) <EOL> @ classmethod <EOL> def validate ( cls , obj , raiseException = False , complainUnrecognized = False ) : <EOL> """<STR_LIT>""" <EOL> if not cls . allowGroup and obj . group is not None : <EOL> err = str ( obj ) + "<STR_LIT>" <EOL> raise base . VObjectError ( err ) <EOL> if isinstance ( obj , base . ContentLine ) : <EOL> return cls . lineValidate ( obj , raiseException , complainUnrecognized ) <EOL> elif isinstance ( obj , base . Component ) : <EOL> count = { } <EOL> for child in obj . getChildren ( ) : <EOL> if not child . validate ( raiseException , complainUnrecognized ) : <EOL> return False <EOL> name = child . name . upper ( ) <EOL> count [ name ] = count . get ( name , <NUM_LIT:0> ) + <NUM_LIT:1> <EOL> for key , val in cls . knownChildren . iteritems ( ) : <EOL> if count . get ( key , <NUM_LIT:0> ) < val [ <NUM_LIT:0> ] : <EOL> if raiseException : <EOL> m = "<STR_LIT>" <EOL> raise base . ValidateError ( m % ( cls . name , val [ <NUM_LIT:0> ] , key ) ) <EOL> return False <EOL> if val [ <NUM_LIT:1> ] and count . get ( key , <NUM_LIT:0> ) > val [ <NUM_LIT:1> ] : <EOL> if raiseException : <EOL> m = "<STR_LIT>" <EOL> raise base . ValidateError ( m % ( cls . name , val [ <NUM_LIT:1> ] , key ) ) <EOL> return False <EOL> return True <EOL> else : <EOL> err = str ( obj ) + "<STR_LIT>" <EOL> raise base . VObjectError ( err ) <EOL> @ classmethod <EOL> def lineValidate ( cls , line , raiseException , complainUnrecognized ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> @ classmethod <EOL> def decode ( cls , line ) : <EOL> if line . encoded : line . encoded = <NUM_LIT:0> <EOL> @ classmethod <EOL> def encode ( cls , line ) : <EOL> if not line . encoded : line . encoded = <NUM_LIT:1> <EOL> @ classmethod <EOL> def transformToNative ( cls , obj ) : <EOL> """<STR_LIT>""" <EOL> return obj <EOL> @ classmethod <EOL> def transformFromNative ( cls , obj ) : <EOL> """<STR_LIT>""" <EOL> raise base . NativeError ( "<STR_LIT>" ) <EOL> @ classmethod <EOL> def generateImplicitParameters ( cls , obj ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> @ classmethod <EOL> def serialize ( cls , obj , buf , lineLength , validate = True ) : <EOL> """<STR_LIT>""" <EOL> cls . generateImplicitParameters ( obj ) <EOL> if validate : cls . validate ( obj , raiseException = True ) <EOL> if obj . isNative : <EOL> transformed = obj . transformFromNative ( ) <EOL> undoTransform = True <EOL> else : <EOL> transformed = obj <EOL> undoTransform = False <EOL> out = base . defaultSerialize ( transformed , buf , lineLength ) <EOL> if undoTransform : obj . transformToNative ( ) <EOL> return out <EOL> @ classmethod <EOL> def valueRepr ( cls , line ) : <EOL> """<STR_LIT>""" <EOL> return line . value </s>
