summaryrefslogtreecommitdiff
path: root/Mozo/util.py
diff options
context:
space:
mode:
authorJasper St. Pierre <[email protected]>2012-05-09 15:31:37 -0300
committerAlexei Sorokin <[email protected]>2016-08-22 23:03:32 +0300
commit41bebb09eec4c7087f7fd5ad0ae595af8401627e (patch)
tree0f5a283e549f2c65c3365c5f34f760627d47e757 /Mozo/util.py
parente71b7979a236e4017c34a4b482ecd66c518ef4e2 (diff)
downloadmozo-41bebb09eec4c7087f7fd5ad0ae595af8401627e.tar.bz2
mozo-41bebb09eec4c7087f7fd5ad0ae595af8401627e.tar.xz
MenuEditor: put removeWhitespaceNodes somewhere else
Diffstat (limited to 'Mozo/util.py')
-rw-r--r--Mozo/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Mozo/util.py b/Mozo/util.py
index cc7db83..2688c4b 100644
--- a/Mozo/util.py
+++ b/Mozo/util.py
@@ -17,6 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
+import xml.dom.minidom
import matemenu
import gi
from collections import Sequence
@@ -171,3 +172,15 @@ def getIcon(item, for_properties=False):
if for_properties:
return pixbuf, path
return pixbuf
+
+def removeWhitespaceNodes(node):
+ remove_list = []
+ for child in node.childNodes:
+ if child.nodeType == xml.dom.minidom.Node.TEXT_NODE:
+ child.data = child.data.strip()
+ if not child.data.strip():
+ remove_list.append(child)
+ elif child.hasChildNodes():
+ removeWhitespaceNodes(child)
+ for node in remove_list:
+ node.parentNode.removeChild(node)