Package pyvb :: Module state
[hide private]
[frames] | no frames]

Source Code for Module pyvb.state

 1  """state - Holds abstractions related to VirtualMachine states.""" 
 2   
 3  from pyvb.constants import * 
 4  from pyvb.parser import * 
 5   
6 -class vbStateParser(vbParser):
7 """A parser for parsing machine state command line output."""
8 - def __init__(self):
9 """Constructor. Initialize the found attributes dictionary 10 as well as the attributes we are looking for. 11 @return: A new L{pyvb.state.vbStateParser} instance. 12 @rtype: L{pyvb.state.vbStateParser}""" 13 self.found_attributes={} 14 self.attributes={'name': VB_RE_STATE_NAME,\ 15 'date': VB_RE_STATE_DATE}
16
17 - def parse(self, file):
18 """Parse the specified file and return the results. 19 @param file: The file to parse. 20 @type file: File/List 21 @return: A list of L{pyvb.state.vbState} instances. 22 @rtype: List""" 23 states=[] 24 for result in self._parse(file): 25 found_state=vbState(name=result['name'],\ 26 date=result['date']) 27 states.append(found_state) 28 return states
29
30 -class vbState:
31 """An abstraction representing a VirtualBox machine state."""
32 - def __init__(self, **kw):
33 """Constructor. Initialize the attributes. 34 @return: A new L{pyvb.state.vbState} instance. 35 @rtype: L{pyvb.state.vbState}""" 36 try: 37 self.setName(kw['name']) 38 except KeyError: 39 self.setName('') 40 try: 41 self.setDate(kw['date']) 42 except KeyError: 43 self.setDate('')
44
45 - def setName(self, name):
46 """Set the name attribute of this L{pyvb.state.vbState} instance. 47 @param name: The name attribute. 48 @type name: String 49 @return: None 50 @rtype: None""" 51 self.name=name
52
53 - def setDate(self, date):
54 """Set the date attribute of this L{pyvb.state.vbState} instance. 55 @param date: The date attribute. 56 @type date: String 57 @return: None 58 @rtype: None""" 59 self.date=date
60
61 - def getName(self):
62 """Return the name attribute of this L{pyvb.state.vbState} instance. 63 @return: The name attribute. 64 @rtype: String""" 65 return self.name
66
67 - def getDate(self):
68 """Return the date attribute of this L{pyvb.state.vbState} instance. 69 @return: The date attribute. 70 @rtype: String""" 71 return self.date
72