def PrettyPrintEnums(raw_xml): """Pretty print the given enums XML.""" root = etree_util.ParseXMLString(raw_xml) # Prevent accidentally adding histograms to enums.xml DropNodesByTagName(root, 'histograms') DropNodesByTagName(root, 'histogram_suffixes_list') top_level_content = etree_util.GetTopLevelContent(raw_xml) formatted_xml = histogram_configuration_model.PrettifyTree(root) return top_level_content + formatted_xml
def PrettyPrintHistograms(raw_xml): """Pretty-print the given histograms XML. Args: raw_xml: The contents of the histograms XML file, as a string. Returns: The pretty-printed version. """ top_level_content = etree_util.GetTopLevelContent(raw_xml) root = etree_util.ParseXMLString(raw_xml) return top_level_content + PrettyPrintHistogramsTree(root)
def PrettyPrintEnums(raw_xml): """Pretty print the given enums XML.""" root = etree_util.ParseXMLString(raw_xml) # Prevent accidentally adding histograms to enums.xml DropNodesByTagName(root, 'histograms') DropNodesByTagName(root, 'histogram_suffixes_list') top_level_content = etree_util.GetTopLevelContent(raw_xml) formatted_xml = ( histograms_print_style.GetPrintStyle().PrettyPrintXml(root)) return top_level_content + formatted_xml
def _PrettyPrintMinidom(self, doc): """Transforms minidom to ElementTree before pretty printing it.""" raw_xml = doc.toxml() # minidom prepends a document type, so remove it. raw_xml = raw_xml.replace(minidom.Document().toxml(), '') etree_root = etree_util.ParseXMLString(raw_xml) top_content = etree_util.GetTopLevelContent(raw_xml) # Add newlines between top-level comments. top_content = top_content.replace('--><!--', '-->\n\n<!--') formatted_xml = self.PrettyPrintXml(etree_root) return top_content + formatted_xml