Package Peach :: Package Engine :: Module incoming :: Class DataCracker
[hide private]

Class DataCracker

source code

This class will try and parse data into a data model. This process will try and best-fit data based on performing look aheads with fit-ratings.

Instance Methods [hide private]
 
__init__(self, peachXml, inner=False) source code
 
crackData(self, template, data, method='setValue')
Crack data based on template.
source code
 
_resetDataElementValues(self, node, method)
Reset values in data tree to None.
source code
 
getInitialReadSize(self, template)
Determin the initial read size for this template.
source code
 
_handleNodeSize(self, node, data, pos, parent)
Try and determine size of a node.
source code
 
_handleStringSize(self, node, data, pos, parent) source code
 
_handleBlobSize(self, node, data, pos, parent) source code
 
_handleNumberSize(self, node, data, pos, parent) source code
 
_handleFlagsSize(self, node, data, pos, parent) source code
 
_handleBlockSize(self, node, data, pos, parent) source code
 
_GetTemplateByName(self, str)
Get the object indicated by ref.
source code
 
_getRootParent(self, node) source code
 
_fixRealParent(self, node) source code
 
_unFixRealParent(self, node) source code
 
_handleNode(self, node, data, pos, parent=None, doingMinMax=False) source code
 
_lookAhead(self, node, data, pos, parent, minMax=True)
Look ahead one step and get the next rating.
source code
 
_nextNode(self, node)
Locate the next node.
source code
 
_adjustRating(self, rating, lookAheadRating) source code
 
_handleChoice(self, node, data, pos, parent, doingMinMax=False) source code
 
_handleBlock(self, node, data, pos, parent, doingMinMax=False) source code
 
_getDataFromFullname(self, dom, name)
Take a fullname (blah.blah.blah) and locate it in our data dom.
source code
 
_handleString(self, node, data, pos, parent, doingMinMax=False)
Returns the rating and string.
source code
 
_handleNumber(self, node, data, pos, parent, doingMinMax=False)
Handle Number.
source code
 
_handleFlags(self, node, data, pos, parent, doingMinMax=False)
Returns the rating and string.
source code
 
_handleBlob(self, node, data, pos, parent, doingMinMax=False)
Returns the rating and string.
source code
Class Variables [hide private]
  _tabLevel = 0
Method Details [hide private]

crackData(self, template, data, method='setValue')

source code 

Crack data based on template. Set values into data tree.

Will throw an exception (NeedMoreData) if additional data is required. The exception contains the minimum amount of additional data needed before trying to re-crack the data.

_handleNodeSize(self, node, data, pos, parent)

source code 

Try and determine size of a node.

Rating of:

  1 - Exact
  2 - Exact, but not everything
  3 - Not complete to block yet
  4 - Nadda

_GetTemplateByName(self, str)

source code 

Get the object indicated by ref. Currently the object must have been defined prior to this point in the XML

_lookAhead(self, node, data, pos, parent, minMax=True)

source code 

Look ahead one step and get the next rating. Looking ahead from a current node is more complex than it might first seem.

For example, we might be the 2nd to last element in a block that is part of a larger block (but not the last element). We will need to be tricky inorder to properly look ahead at the rest of the document.

_nextNode(self, node)

source code 

Locate the next node.

1. Do we have a .nextSibling?
2. Does are parent have .nextSibling?
...

Need to also support escaping Choice blocks!            

_handleString(self, node, data, pos, parent, doingMinMax=False)

source code 

Returns the rating and string. The rating is how well we matched.

Rating:

1 - BEST If our default matched and look ahead is 1 2 - GOOD If our default matched and look ahead is 2 3 - OK If our look ahead is 1 or 2 4 - MPH If look ahead is 3 or 4

_handleNumber(self, node, data, pos, parent, doingMinMax=False)

source code 

Handle Number. Return (rating, newpos, value) in tuple.

Rating:

1 - BEST If our default matched and look ahead is 1 2 - GOOD If our default matched and look ahead is 2 3 - OK If our look ahead is 1 or 2 4 - MPH If look ahead is 3 or 4

_handleFlags(self, node, data, pos, parent, doingMinMax=False)

source code 

Returns the rating and string. The rating is how well we matched.

Rating:

1 - BEST If our default matched and look ahead is 1 2 - GOOD If our default matched and look ahead is 2 3 - OK If our look ahead is 1 or 2 4 - MPH If look ahead is 3 or 4

_handleBlob(self, node, data, pos, parent, doingMinMax=False)

source code 

Returns the rating and string. The rating is how well we matched.

Rating:

1 - BEST If our default matched and look ahead is 1 2 - GOOD If our default matched and look ahead is 2 3 - OK If our look ahead is 1 or 2 4 - MPH If look ahead is 3 or 4