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

Source Code for Module pyvb.dvd

  1  """ 
  2  dvd - pyvb module that holds the implementation of all DVD related abstractions. 
  3  """ 
  4  from pyvb.constants import * 
  5  from pyvb.parser import * 
  6   
7 -class vbHostDvdParser(vbParser):
8 """A parser for parsing the command line output related to the host DVD."""
9 - def __init__(self):
10 """Constructor. Initialize the found attributes and the attributes 11 we are looking for. 12 @return: A new L{pyvb.dvd.vbHostDvdParser} instance. 13 @rtype: L{pyvb.dvd.vbHostDvdParser}""" 14 self.found_attributes={} 15 self.attributes={'name':VB_RE_NAME}
16
17 - def parse(self, file):
18 """Parse the specified file for a host DVD. 19 @param file: The file to parse. 20 @type file: File 21 @return: A list of L{pyvb.dvd.vbHostDvd} instances. 22 @rtype: List""" 23 hostdvds=[] 24 for result in self._parse(file): 25 found_hostdvd=vbHostDvd(name=result['name']) 26 hostdvds.append(found_hostdvd) 27 return hostdvds
28
29 -class vbDvdParser(vbParser):
30 """A parser for parsing the command line output related to virtual machine 31 DVDs."""
32 - def __init__(self):
33 """Constructor. Initialize the found attributes and the attributes 34 we are looking for. 35 @return: A new L{pyvb.dvd.vbDvdParser} instance. 36 @rtype: L{pyvb.dvd.vbDvdParser}""" 37 self.found_attributes={} 38 self.attributes={'uuid':VB_RE_UUID,\ 39 'path':VB_RE_PATH,\ 40 'accessible':VB_RE_ACCESSIBLE}
41
42 - def parse(self, file):
43 """Parse the specified file for a virtual machine DVD. 44 @param file: The file to parse. 45 @type file: File 46 @return: A list of L{pyvb.dvd.vbDvd} instances. 47 @rtype: List""" 48 dvds=[] 49 for result in self._parse(file): 50 found_dvd=vbDvd(uuid=result['uuid'],\ 51 path=result['path'],\ 52 accessible=result['accessible']) 53 dvds.append(found_dvd) 54 return dvds
55
56 -class vbHostDvd:
57 """An abstraction representing a host DVD."""
58 - def __init__(self, **kw):
59 """Constructor. Initialize the attributes. 60 @return: A new L{pyvb.dvd.vbHostDvd} instance. 61 @rtype: L{pyvb.dvd.vbHostDvd}""" 62 try: 63 self.setName(kw['name']) 64 except KeyError: 65 self.setName('')
66
67 - def setName(self, name):
68 """Set the name attribute of this L{pyvb.dvd.vbHostDvd} instance. 69 @param name: The name attribute. 70 @type name: String 71 @return: None 72 @rtype: None""" 73 self.name=name
74
75 - def getName(self):
76 """Return the name attribute of this L{pyvb.dvd.vbHostDvd} instenace. 77 @return: The name attribute. 78 @rtype: String""" 79 return self.name
80
81 -class vbDvd:
82 """An abstraction representing a virtual machine DVD."""
83 - def __init__(self, **kw):
84 """Constructor. Initialize the attributes. 85 @return: A new L{pyvb.dvd.vbDvd} instance. 86 @rtype: L{pyvb.dvd.vbDvd}""" 87 try: 88 self.setUUID(kw['uuid']) 89 except KeyError: 90 self.setUUID('') 91 try: 92 self.setPath(kw['path']) 93 except KeyError: 94 self.setPath('') 95 try: 96 self.setAccessible(kw['accessible']) 97 except KeyError: 98 self.setAccessible('')
99
100 - def setUUID(self, uuid):
101 """Set the uuid attribute of this L{pyvb.dvd.vbDvd} instance. 102 @param uuid: The uuid attribute. 103 @type uuid: String 104 @return: None 105 @rtype: None""" 106 self.uuid=uuid
107
108 - def setPath(self, path):
109 """Set the path attribute of this L{pyvb.dvd.vbDvd} instance. 110 @param path: The path attribute. 111 @type path: String 112 @return: None 113 @rtype: None""" 114 self.path=path
115
116 - def setAccessible(self, accessible):
117 """Set the accessible attribute of this L{pyvb.dvd.vbDvd} instance. 118 @param accessible: The accessible attribute. 119 @type accessible: String 120 @return: None 121 @rtype: None""" 122 self.accessible=accessible
123
124 - def getUUID(self):
125 """Return the uuid attribute of this L{pyvb.dvd.vbDvd} instance. 126 @return: The uuid attribute. 127 @rtype: String""" 128 return self.uuid
129
130 - def getPath(self):
131 """Return the path attribute of this L{pyvb.dvd.vbDvd} instance. 132 @return: The path attribute. 133 @rtype: String""" 134 return self.path
135
136 - def getAccessible(self):
137 """Return the accessible attribute of this L{pyvb.dvd.vbDvd} instance. 138 @return: The path attribute. 139 @rtype: String""" 140 return self.accessible
141