Package VMBuilder :: Module frontend'
[frames] | no frames]

Source Code for Module VMBuilder.frontend'

 1  # 
 2  #    Uncomplicated VM Builder 
 3  #    Copyright (C) 2007-2008 Canonical Ltd. 
 4  #     
 5  #    See AUTHORS for list of contributors 
 6  # 
 7  #    This program is free software: you can redistribute it and/or modify 
 8  #    it under the terms of the GNU General Public License as published by 
 9  #    the Free Software Foundation, either version 3 of the License, or 
10  #    (at your option) any later version. 
11  # 
12  #    This program is distributed in the hope that it will be useful, 
13  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  #    GNU General Public License for more details. 
16  # 
17  #    You should have received a copy of the GNU General Public License 
18  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
19  # 
20  #    Frontend interface and classes 
21   
22  import VMBuilder 
23  import optparse 
24   
25 -class Frontend(object):
26 - def __init__(self):
27 self.settings = []
28
29 - def setting_group(self, help=None):
30 return self.SettingsGroup(help)
31
32 - def add_setting_group(self, group):
33 self.settings.append(group)
34
35 - def add_setting(self, **kwargs):
36 self.settings.append(Setting(**kwargs))
37 38 setting_types = ['store', 'store']
39 - class Setting(object):
40 - def __init__(self, **kwargs):
41 self.shortarg = kwargs.get('shortarg', None) 42 self.longarg = kwargs.get('shortarg', None) 43 self.default = kwargs.get('default', None) 44 self.help = kwargs.get('help', None) 45 type = kwargs.get('type', 'store') 46 if type not in setting_types: 47 raise VMBuilderException("Invalid option type: %s" % type)
48
49 - class SettingsGroup(Setting):
50 pass
51