Fixing & updating Debian changelog
[guimicrodia.git] / src / fixGlade.py
blob30456b8e70e2c840dbacef13a251e7a1a2f74d87
1 #!/usr/bin/env python
2 # a quick script to fix Glade v3.4.0 XML errors
3 # - removes an unnecessary <property name="response_id">0</property> line / string
4 # - Changes to comply with gtk-builder format
5 # the workflow is Glade -> fix_errata -> convert to GTK-Builder XML
7 # You must have gtk-builder-convert installed on your system
9 # Copyright 2008 Neekhil <Nickel62Metal@Gmail.com>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License with
22 # the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL-3;
23 # if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
26 __version__ = "1.00"
27 __author__ = "Neekhil <Nickel62Metal@Gmail.com>"
28 __date__ = "$ 28 Sep 2008 $"
30 import os
31 from os import system
32 import sys
34 def determine_path ():
35 """Borrowed from wxglade.py"""
36 try:
37 root = __file__
38 if os.path.islink (root):
39 root = os.path.realpath (root)
40 return os.path.dirname (os.path.abspath (root))
41 except:
42 print "I'm sorry, but something is wrong."
43 print "There is no __file__ variable. Please contact the author."
44 sys.exit ()
46 original = open(determine_path () +"/MicrodiaV4.glade","r")
47 fixed = open(determine_path () +"/MicrodiaV4-fixed.glade",'w')
48 to_be_deleted = "<property name=\"response_id\">0</property>"
50 lines = original.readlines()
52 for line in lines:
53 if line.find(to_be_deleted) == -1:
54 fixed.write(line)
55 fixed.close()
56 original.close()
58 temp1 = determine_path () + "/MicrodiaV4-fixed.glade"
59 temp2 = determine_path () + "/MicrodiaV4.xml"
61 system("gtk-builder-convert "+temp1+" "+temp2)
62 system("rm "+temp1)