<s> from toscaparser . common . exception import ExceptionCollector <EOL> from toscaparser . common . exception import InvalidTypeError <EOL> from toscaparser . elements . attribute_definition import AttributeDef <EOL> from toscaparser . elements . entity_type import EntityType <EOL> from toscaparser . elements . property_definition import PropertyDef <EOL> class StatefulEntityType ( EntityType ) : <EOL> '''<STR_LIT>''' <EOL> interfaces_node_lifecycle_operations = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:start>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> interfaces_relationship_configure_operations = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> def __init__ ( self , entitytype , prefix , custom_def = None ) : <EOL> entire_entitytype = entitytype <EOL> if not entitytype . startswith ( self . TOSCA ) : <EOL> entire_entitytype = prefix + entitytype <EOL> if entire_entitytype in list ( self . TOSCA_DEF . keys ( ) ) : <EOL> self . defs = self . TOSCA_DEF [ entire_entitytype ] <EOL> entitytype = entire_entitytype <EOL> elif custom_def and entitytype in list ( custom_def . keys ( ) ) : <EOL> self . defs = custom_def [ entitytype ] <EOL> else : <EOL> self . defs = None <EOL> ExceptionCollector . appendException ( <EOL> InvalidTypeError ( what = entitytype ) ) <EOL> self . type = entitytype <EOL> def get_properties_def_objects ( self ) : <EOL> '''<STR_LIT>''' <EOL> properties = [ ] <EOL> props = self . get_definition ( self . PROPERTIES ) <EOL> if props : <EOL> for prop , schema in props . items ( ) : <EOL> properties . append ( PropertyDef ( prop , None , schema ) ) <EOL> return properties <EOL> def get_properties_def ( self ) : <EOL> '''<STR_LIT>''' <EOL> return { prop . name : prop <EOL> for prop in self . get_properties_def_objects ( ) } <EOL> def get_property_def_value ( self , name ) : <EOL> '''<STR_LIT>''' <EOL> props_def = self . get_properties_def ( ) <EOL> if props_def and name in props_def . keys ( ) : <EOL> return props_def [ name ] . value <EOL> def get_attributes_def_objects ( self ) : <EOL> '''<STR_LIT>''' <EOL> attrs = self . get_value ( self . ATTRIBUTES , parent = True ) <EOL> if attrs : <EOL> return [ AttributeDef ( attr , None , schema ) <EOL> for attr , schema in attrs . items ( ) ] <EOL> return [ ] <EOL> def get_attributes_def ( self ) : <EOL> '''<STR_LIT>''' <EOL> return { attr . name : attr <EOL> for attr in self . get_attributes_def_objects ( ) } <EOL> def get_attribute_def_value ( self , name ) : <EOL> '''<STR_LIT>''' <EOL> attrs_def = self . get_attributes_def ( ) <EOL> if attrs_def and name in attrs_def . keys ( ) : <EOL> return attrs_def [ name ] . value </s>
