mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Prettify the output by running it through xmllint --format if xmllint is
2007-06-28 Johan Dahlin <jdahlin@async.com.br> * gtk/gtk-builder-convert (_indent): Prettify the output by running it through xmllint --format if xmllint is available which also requires the subprocess module only available in python 2.4 or later svn path=/trunk/; revision=18281
This commit is contained in:
parent
3709aee045
commit
118f2e6483
@ -1,3 +1,10 @@
|
|||||||
|
2007-06-28 Johan Dahlin <jdahlin@async.com.br>
|
||||||
|
|
||||||
|
* gtk/gtk-builder-convert (_indent): Prettify the output by
|
||||||
|
running it through xmllint --format if xmllint is available
|
||||||
|
which also requires the subprocess module only available
|
||||||
|
in python 2.4 or later
|
||||||
|
|
||||||
2007-06-28 Christian Persch <chpe@gnome.org>
|
2007-06-28 Christian Persch <chpe@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkvolumebutton.c: (gtk_volume_button_class_init),
|
* gtk/gtkvolumebutton.c: (gtk_volume_button_class_init),
|
||||||
|
@ -25,10 +25,18 @@
|
|||||||
# GtkTextView.text -> GtkTextBuffer
|
# GtkTextView.text -> GtkTextBuffer
|
||||||
# Toolbars
|
# Toolbars
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from xml.dom import minidom, Node
|
from xml.dom import minidom, Node
|
||||||
|
|
||||||
|
# The subprocess is only available in Python 2.4+
|
||||||
|
try:
|
||||||
|
import subprocess
|
||||||
|
subprocess # pyflakes
|
||||||
|
except ImportError:
|
||||||
|
subprocess = None
|
||||||
|
|
||||||
def get_child_nodes(node):
|
def get_child_nodes(node):
|
||||||
nodes = []
|
nodes = []
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
@ -354,14 +362,34 @@ class GtkBuilderConverter(object):
|
|||||||
widget.getAttributeNode("constructor").value = parent_id
|
widget.getAttributeNode("constructor").value = parent_id
|
||||||
node.removeAttribute("id")
|
node.removeAttribute("id")
|
||||||
|
|
||||||
|
def _indent(output):
|
||||||
|
if not subprocess:
|
||||||
|
return output
|
||||||
|
|
||||||
|
for directory in os.environ['PATH'].split(os.pathsep):
|
||||||
|
filename = os.path.join(directory, 'xmllint')
|
||||||
|
if os.path.exists(filename):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return output
|
||||||
|
|
||||||
|
s = subprocess.Popen([filename, '--format', '-'],
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
s.stdin.write(output)
|
||||||
|
s.stdin.close()
|
||||||
|
return s.stdout.read()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "Usage: %s filename.glade" % (sys.argv[0],)
|
raise SystemExit("Usage: %s filename.glade" % (sys.argv[0],))
|
||||||
return
|
|
||||||
conv = GtkBuilderConverter()
|
conv = GtkBuilderConverter()
|
||||||
conv.parse_file(sys.argv[1])
|
conv.parse_file(sys.argv[1])
|
||||||
print conv.to_xml()
|
|
||||||
|
xml = conv.to_xml()
|
||||||
|
print _indent(xml)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user