#NEWLINE# def __init__( self , template = None , uuid = None , url = None , xml = None ) : #NEWLINE# #INDENT# self . log = logging . getLogger ( ( '%s.%s' % ( __name__ , self . __class__ . __name__ ) ) ) #NEWLINE# self . identifier = None #NEWLINE# self . url = None #NEWLINE# self . xml = None #NEWLINE# path = None #NEWLINE# if template : #NEWLINE# #INDENT# template_string = str ( template ) #NEWLINE# template_string_type = self . __template_string_type ( template_string ) #NEWLINE# if ( template_string_type == 'UUID' ) : #NEWLINE# #INDENT# uuid = template_string #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( template_string_type == 'URL' ) : #NEWLINE# #INDENT# url = template_string #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( template_string_type == 'XML' ) : #NEWLINE# #INDENT# xml = template_string #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( template_string_type == 'PATH' ) : #NEWLINE# #INDENT# path = template_string #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if uuid : #NEWLINE# #INDENT# uuid_string = uuid #NEWLINE# ( self . identifier , self . xml ) = self . __fetch_template_for_uuid ( uuid_string ) #NEWLINE# if ( ( not self . identifier ) and ( not self . xml ) ) : #NEWLINE# #INDENT# raise RuntimeError ( ( 'Could not create a template with the uuid %s' % ( uuid , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if url : #NEWLINE# #INDENT# self . url = url #NEWLINE# ( self . identifier , self . xml ) = self . __fetch_template_with_url ( url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if xml : #NEWLINE# #INDENT# self . xml = xml #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if path : #NEWLINE# #INDENT# template_file = open ( path , 'r' ) #NEWLINE# file_content = template_file . read ( ) #NEWLINE# template_file . close ( ) #NEWLINE# if self . __string_is_xml_template ( file_content ) : #NEWLINE# #INDENT# self . xml = file_content #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( ( 'File %s does not contain properly formatted template xml:\n%s' % ( path , self . __abbreviated_template ( file_content ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( "'template' must be a UUID, URL, XML string or XML document path..." )