Fix default value for codelite files checkbox.
[bertos.git] / wizard / winreg_importer.py
1 #!/usr/bin/env python\r
2 # encoding: utf-8\r
3 #\r
4 # This file is part of BeRTOS.\r
5 #\r
6 # Bertos is free software; you can redistribute it and/or modify\r
7 # it under the terms of the GNU General Public License as published by\r
8 # the Free Software Foundation; either version 2 of the License, or\r
9 # (at your option) any later version.\r
10 #\r
11 # This program is distributed in the hope that it will be useful,\r
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 # GNU General Public License for more details.\r
15 #\r
16 # You should have received a copy of the GNU General Public License\r
17 # along with this program; if not, write to the Free Software\r
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
19 #\r
20 # As a special exception, you may use this file as part of a free software\r
21 # library without restriction.  Specifically, if other files instantiate\r
22 # templates or use macros or inline functions from this file, or you compile\r
23 # this file and link it with other files to produce an executable, this\r
24 # file does not by itself cause the resulting executable to be covered by\r
25 # the GNU General Public License.  This exception does not however\r
26 # invalidate any other reasons why the executable file might be covered by\r
27 # the GNU General Public License.\r
28 #\r
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)\r
30 #\r
31 # $Id: qvariant_converter.py 2506 2009-04-15 08:29:07Z duplo $\r
32 #\r
33 # Author: Lorenzo Berni <duplo@develer.com>\r
34 #\r
35 \r
36 from _winreg import *\r
37 \r
38 # Open the registry keys. When the keys don't exist it do nothing\r
39 try:\r
40     DIR_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\BeRTOS Dirs")\r
41 except WindowsError:\r
42     DIR_KEY = None\r
43 \r
44 try:\r
45     TOOLCHAIN_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Toolchain Executables")\r
46 except WindowsError:\r
47     TOOLCHAIN_KEY = None\r
48 \r
49 try:\r
50     CLI_KEY = OpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Develer\BeRTOS SDK\Ide Command Lines")\r
51 except WindowsError:\r
52     CLI_KEY = None\r
53 \r
54 def getBertosDirs():\r
55     """\r
56     Returns the path of the BeRTOS versions installed by the BeRTOS SDK installer.\r
57     """\r
58     return getFromRegistry(DIR_KEY).values()\r
59 \r
60 def getBertosToolchains():\r
61     """\r
62     Returns the path of the executables of the toolchains installed by the BeRTOS\r
63     SDK installer.\r
64     """\r
65     return getFromRegistry(TOOLCHAIN_KEY).values()\r
66 \r
67 def getCommandLines():\r
68     """\r
69     Returns the command lines to launch in order to open the selected IDE.\r
70     """\r
71     return getFromRegistry(CLI_KEY)\r
72 \r
73 def getFromRegistry(key):\r
74     """\r
75     Returns the value of all the named values of the given key.\r
76     """\r
77     index = 0\r
78     items = {}\r
79     if key:\r
80         while True:\r
81             try:\r
82                 item = EnumValue(key, index)\r
83                 items[item[0]] = item[1]\r
84                 index += 1\r
85             except WindowsError:\r
86                 break\r
87     return items