[kde-services-devel] r488 - trunk/scripts/ghns
josef at new.kstuff.org
josef at new.kstuff.org
Fri Nov 21 20:34:36 CET 2008
Author: josef
Date: 2008-11-21 20:34:36 +0100 (Fri, 21 Nov 2008)
New Revision: 488
Added:
trunk/scripts/ghns/ghns-from-desktop.py
Log:
- new script to merge *.desktop translations into *.meta files
- doesn't work yet due to some Python utf-8 encoding issue
Added: trunk/scripts/ghns/ghns-from-desktop.py
===================================================================
--- trunk/scripts/ghns/ghns-from-desktop.py (rev 0)
+++ trunk/scripts/ghns/ghns-from-desktop.py 2008-11-21 19:34:36 UTC (rev 488)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Updates .meta file from .desktop file
+# Syntax: ghns-from-desktop.py <metafile> <desktopfile>
+
+import xml.dom.minidom
+import sys
+import ConfigParser
+
+if len(sys.argv) != 3:
+ print "Syntax: ghns-from-desktop.py <metafile> <desktopfile>"
+ sys.exit(1)
+
+metafile = sys.argv[1]
+desktopfile = sys.argv[2]
+
+dom = xml.dom.minidom.parse(metafile)
+stuff = dom.getElementsByTagName("stuff")[0]
+
+cp = ConfigParser.ConfigParser()
+cp.read(desktopfile)
+
+items = cp.items("KGameTheme")
+
+for item in items:
+ (key, value) = item
+ if key[:4] == "name" and len(key) > 4:
+ namevalue = value
+ lang = key[5:7]
+
+ name = dom.createElement("name")
+ name.setAttribute("lang", lang)
+ nametext = dom.createTextNode(namevalue)
+ name.appendChild(nametext)
+
+ br = dom.createTextNode("\n ")
+ stuff.appendChild(br)
+ stuff.appendChild(name)
+ elif key[:11] == "description" and len(key) > 11:
+ descvalue = value
+ lang = key[12:14]
+
+ desc = dom.createElement("summary")
+ desc.setAttribute("lang", lang)
+ desctext = dom.createTextNode(descvalue)
+ desc.appendChild(desctext)
+
+ br = dom.createTextNode("\n ")
+ stuff.appendChild(br)
+ stuff.appendChild(desc)
+
+out = dom.toxml("utf-8")
+#out = out.encode("utf-8", "replace")
+
+outfile = open(metafile + ".X", "w")
+outfile.write(out)
+outfile.close()
+
Property changes on: trunk/scripts/ghns/ghns-from-desktop.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the kde-services-devel
mailing list