1 """sharedfolder - Holds abstractions related to VirtualBox shared folders."""
2
3 from pyvb.constants import *
4 from pyvb.parser import *
5
7 """A parser for parsing shared folder command line output."""
9 """Constructor. Initialize the found attributes dictionary
10 as well as the attributes we are looking for.
11 @return: A new L{pyvb.sharedfolder.vbSharedFolderParser}
12 @rtype: L{pyvb.sharedfolder.vbSharedFolderParser}"""
13 self.found_attributes={}
14 self.attributes={'name': VB_RE_SHAREDFOLDER_PATH,\
15 'path': VB_RE_SHAREDFOLDER_PATH}
16
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.sharedfolder.vbSharedFolder} instances.
22 @rtype: List"""
23 shared_folders=[]
24 for result in self._parse(file):
25 found_folder=vbSharedFolder(name=result['name'],\
26 path=result['path'])
27 shared_folders.append(found_folder)
28 return shared_folders
29
31 """An abstraction representing a VirtualBox shared folder."""
33 """Constructor. Initialize attributes.
34 @return: A new L{pyvb.sharedfolder.vbSharedFolder} instance.
35 @rtype: L{pyvb.sharedfolder.vbSharedFolder}"""
36 try:
37 self.setName(kw['name'])
38 except KeyError:
39 self.setName('')
40 try:
41 self.setPath(kw['path'])
42 except KeyError:
43 self.setName('')
44
46 """Set the name attribute of this L{pyvb.sharedfolder.vbSharedFolder} instance.
47 @param name: The name attribute.
48 @type name: String
49 @return: None
50 @rtype: None"""
51 self.name=name
52
54 """Set the path attribute of this L{pyvb.sharedfolder.vbSharedFolder} instance.
55 @param path: The path attribute.
56 @type path: String
57 @return: None
58 @rtype: None"""
59 self.path=path
60
62 """Return the name attribute of this L{pyvb.sharedfolder.vbSharedFolder} instance.
63 @return: The name attribute.
64 @rtype: String"""
65 return self.name
66
68 """Return the path attribute of this L{pyvb.sharedfolder.vbSharedFolder} instance.
69 @return: The path attribute.
70 @rtype: String"""
71 return self.path
72