³ò ù¯ÖEc@s:d„Zd„Zd„Zd„Zd„Zd„ZdS(cCscddkl}t|ƒtjo |‚nddkl}||ƒ}t|ƒt|ƒ}|S(sà Get templates from an XML template file. @param filename: The path to an XML template file. @type filename: A String object. @return: Template information contained in an XML file or nothing. @rtype: A List object. iÿÿÿÿ(tInvalidFileError(tparse(t ExceptionsRt is_xml_filetFalsetxml.dom.minidomRtvalidate_xml_documentt get_templates(tfilenameRRt xml_documentt templates((s)plugins/TemplateEditor/ReadXMLTemplate.pytget_template_from_files    cCs@ddkl}||ƒ}t|ƒt|ƒ}|iƒ|S(sê Get templates from an XML template string. @param string: A string containing XML template information. @type string: A String object. @return: Template information contained in an XML file or nothing. @rtype: A List object. iÿÿÿÿ(t parseString(RR RRtunlink(tstringR R R ((s)plugins/TemplateEditor/ReadXMLTemplate.pytget_template_from_string's     cCsbddkl}l}l}||ƒ}||ƒtjotSn||ƒdjotSntS(s¿ Check whether or not a file is an XML file. @param filename: The path to a file. @type filename: A String object. @return: True if the file is an XML file. @rtype: A Boolean object. iÿÿÿÿ(tget_uri_from_local_pathtexistst get_mime_typestext/xmlsapplication/xml(stext/xmlsapplication/xml(tgnomevfsRRRRtTrue(RRRRturi((s)plugins/TemplateEditor/ReadXMLTemplate.pyR8s  cCs$ddkl}|i}|idgjo tjno |‚n|idƒp |‚n|idƒp |‚n|idƒp |‚n|idƒp |‚n|idƒ}x_|D]W}|idƒtjo |‚n|idƒp |‚n|ii p |‚qÅqÅWd S( s Check whether or not the xml document is a recognizable template format for the text editor. @param xml_document: An object representing an XML document. @type xml_document: An xml.dom.minidom.Document object. @return: True if validation succeeds. @rtype: A Boolean object. iÿÿÿÿ(tValidationErrortsnippettentryttriggert descriptionttemplatetidN( RRtdocumentElementt localNameRtgetElementsByTagNamet hasAttributet getAttributet firstChildtdata(R Rt root_elementt trigger_nodesttrigger_element((s)plugins/TemplateEditor/ReadXMLTemplate.pyRHs  . cCsLg}|i}|idƒ}x'|D]}t|ƒ}|i|ƒq%W|S(sç Get templates from an xml document object. @param xml_document: An object representing an XML document. @type xml_document: An xml.dom.minidom.Document object. @return: Templates in an xml document. @rtype: A List object. R(RRtget_template_from_elementtappend(R R R$t entry_nodest entry_elementR((s)plugins/TemplateEditor/ReadXMLTemplate.pyRas   c Cs¸|idƒd}|ii}|idƒ}}||}|idƒd}d}|io|ii}n|idƒd}d} |io|ii} n||| |f} | S(sù Get template information associated with an entry element in an xml document object. @param entry_element: An element in an XML document object. @type entry_element: An Element object. @return: Data for a template. @rtype: A Tuple object. RiRRtR(RR"R#R!( R*R&Rttrigger_attribute_valuetlanguaget template_keytdescription_elementRttemplate_elementRt template_data((s)plugins/TemplateEditor/ReadXMLTemplate.pyR'ss     N(R RRRRR'(((s)plugins/TemplateEditor/ReadXMLTemplate.pyss