Package pyvb :: Module parser :: Class vbParser
[hide private]
[frames] | no frames]

Class vbParser

source code

The base pyvb parser used to construct Python abstractions of the VirtualBox command line output.

Instance Methods [hide private]
pyvb.parser.vbParser
__init__(self)
Constructor.
source code
List
_parse(self, file)
Construct a list of dictionaries based of the specified file.
source code
List
_parseAdditional(self, file, expression)
Parse the specified file for the specified expression and return the results excluding the first result found.
source code
 
addAttribute(self, name, expression) source code
 
removeAttribute(self, name) source code
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructor.

Returns: pyvb.parser.vbParser
A new pyvb.parser.vbParser instance.

_parse(self, file)

source code 

Construct a list of dictionaries based of the specified file. First we check if we are dealing with a file object of a list object. We iterate through all the lines in the file. If a list parameter was provided, a line is represented by a list element. The inner loop is for the attributes in which we are searching. We match against the attribute's regular expression and add it to the dictionary of found results. The dictionary represnting the current object is considered complete when the number of found attributes matches the number of attributes we are looking for.

Parameters:
  • file (File/List) - The file we are parsing.
Returns: List
A list of parse results.

_parseAdditional(self, file, expression)

source code 

Parse the specified file for the specified expression and return the results excluding the first result found.

Parameters:
  • file (File) - The file we are parsing.
  • expression (Regex) - The expression to match against.
Returns: List
A list of parse results.