AdvancedHTMLParser.xpath._body
index

Copyright (c) 2019 Timothy Savannah under terms of LGPLv3. All Rights Reserved.
 
See LICENSE (https://gnu.org/licenses/lgpl-3.0.txt) for more information.
 
See: https://github.com/kata198/AdvancedHTMLParser for full information
 
 
==INTERNAL==
 
xpath._body.py - Internal module for dealing with items within the "body" of a filter expression on a tag

 
Modules
       
copy
re

 
Classes
       
BodyLevel(BodyElement)
BodyLevel_Top
__builtin__.object
BodyElement
BodyElementOperation
BodyElementValue
BodyElementValueGenerator

 
class BodyElement(__builtin__.object)
    BodyElement - Base class of body elements.
 
  Every distinct "unit" within a body, be it a static value or a function call, or otherwise,
   are subclassed from this type.
 
  Class methods defined here:
createFromMatch(cls, curBodyStr, matchObj) from __builtin__.type
createFromMatch - Create this BodyElement from a given match object, and return the element and remainder for parsing
 
    @param curBodyStr <str> - The current body string (matchObj should have matched at the head of this)
 
    @param matchObj <re.match> - The match object
 
    @return tuple( createdElement<BodyElement>, remainingBodyStr<str> ) - A tuple of the created element and the remaining portion to parse

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class BodyElementOperation(BodyElement)
    BodyElementOperation - Base class of BodyElements which perform some operation against the other body elements
 
 
Method resolution order:
BodyElementOperation
BodyElement
__builtin__.object

Methods defined here:
performOperation(self, leftSide, rightSide)

Class methods inherited from BodyElement:
createFromMatch(cls, curBodyStr, matchObj) from __builtin__.type
createFromMatch - Create this BodyElement from a given match object, and return the element and remainder for parsing
 
    @param curBodyStr <str> - The current body string (matchObj should have matched at the head of this)
 
    @param matchObj <re.match> - The match object
 
    @return tuple( createdElement<BodyElement>, remainingBodyStr<str> ) - A tuple of the created element and the remaining portion to parse

Data descriptors inherited from BodyElement:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class BodyElementValue(BodyElement)
    BodyElementValue - Base class of BodyElements which represent a static or resolved value.
 
  These wrap the native python representation of the values.
 
  A class-level varible, VALUE_TYPE, defines the type associated with the value.
 
 
Method resolution order:
BodyElementValue
BodyElement
__builtin__.object

Methods defined here:
__init__(self, value)
__init__ - Create this element as a wrapper around an already-calculated value
 
 
    @param value <...> - The python-native value to be held by this element.
 
        This will be passed into self.setValue for processing/validation
__repr__(self)
__repr__ - Get a string representation of this value, with code information
getValue(self)
getvalue - Get the value associated with this object
 
 
    @return <...> - The python-native value wrapped by this object
setValue(self, newValue)
setValue - Sets the value associated with this object
 
  This will be called on all value sets, including __init__ (and from regex)
 
 
    @param newValue <???> - The new value for this object

Data and other attributes defined here:
VALUE_TYPE = 0

Class methods inherited from BodyElement:
createFromMatch(cls, curBodyStr, matchObj) from __builtin__.type
createFromMatch - Create this BodyElement from a given match object, and return the element and remainder for parsing
 
    @param curBodyStr <str> - The current body string (matchObj should have matched at the head of this)
 
    @param matchObj <re.match> - The match object
 
    @return tuple( createdElement<BodyElement>, remainingBodyStr<str> ) - A tuple of the created element and the remaining portion to parse

Data descriptors inherited from BodyElement:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class BodyElementValueGenerator(BodyElement)
    BodyElementValueGenerator - Base class of BodyElements which resolve to a BodyValue after execution with context of a tag
 
 
Method resolution order:
BodyElementValueGenerator
BodyElement
__builtin__.object

Methods defined here:
resolveValueFromTag(self, thisTag)
resolveValueFromTag - Process "thisTag" to obtain a BodyElementValue relative to this tag and the extending class's implementation
 
 
    @param thisTag <Tags.AdvancedTag> - The tag of relevance
 
 
    @return <BodyElementValue> - The resulting value

Class methods inherited from BodyElement:
createFromMatch(cls, curBodyStr, matchObj) from __builtin__.type
createFromMatch - Create this BodyElement from a given match object, and return the element and remainder for parsing
 
    @param curBodyStr <str> - The current body string (matchObj should have matched at the head of this)
 
    @param matchObj <re.match> - The match object
 
    @return tuple( createdElement<BodyElement>, remainingBodyStr<str> ) - A tuple of the created element and the remaining portion to parse

Data descriptors inherited from BodyElement:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class BodyLevel_Top(BodyLevel)
    BodyLevel_Top - The topmost level of a body. This is the final evaluation before passing onto the next tag filter
 
 
Method resolution order:
BodyLevel_Top
BodyLevel
BodyElement
__builtin__.object

Methods defined here:
applyFunction = filterTagsByBody(self, currentTags)
filterTagsByBody(self, currentTags)
evaluate - Evaluate the topmost level (and all sub levels), and return tags that match.
 
    For the topmost level, we run all components left-to-right, and evaluate the result.
 
    If an integer remains, we use that 1-origin Nth child of parent.
    If a boolean remains, we use True to retain, False to discard.
 
 
        @param currentTags TagCollection/list<AdvancedTag> - Current set of tags to validate
 
 
        @return TagCollection - The tags which passed validation

Data and other attributes defined here:
VALIDATE_ONLY_BOOLEAN_OR_STR = True

Methods inherited from BodyLevel:
__init__(self)
__init__ - Create this object
__iter__(self)
__iter__ - Iterate over this object
__len__(self)
__len__ - Get number of elements in this group
 
    @return <int> - Number of BodyElements in this group (just this level)
__repr__(self)
__repr__ - Get a string representation of this object as codeish
 
    @return <str> - String repr
appendBodyElement(self, bodyElement)
appendBodyElement - Add a body element to the current tail of this level
 
 
    @param bodyElement <BodyElement> - The body element to add
appendBodyElements(self, bodyElements)
addBodyElements - Add a list of body elements to the current tail of this level
 
 
    @param bodyElements list<BodyElement> - A list of BodyElements to add
evaluateLevelForTag(self, currentTag)
evaluateLevelForTag - Shorthand version of "evaluateLevelForTags" but for one tag
 
 
 
    @param currentTag <AdvancedTag> - A single tag
 
 
    @return <BodyElementValue> - Resulting value for running this level against given tag
 
 
    @see evaluateLevelForTags
evaluateLevelForTags(self, currentTags)
evaluate - Evaluate this level, and return the final value, for each tag.
 
 
    @param currentTags list/TagCollection < AdvancedTag > - The current set of tags to process
 
 
    @return list< BodyElementValue > - The BodyElementValue of the results, in a list 1:1 same order same size as #currentTags
getBodyElements(self)
getBodyElements - Get the body elements associated with this level
 
 
    @return list<BodyElement> - List of BodyElements associated with this level

Class methods inherited from BodyElement:
createFromMatch(cls, curBodyStr, matchObj) from __builtin__.type
createFromMatch - Create this BodyElement from a given match object, and return the element and remainder for parsing
 
    @param curBodyStr <str> - The current body string (matchObj should have matched at the head of this)
 
    @param matchObj <re.match> - The match object
 
    @return tuple( createdElement<BodyElement>, remainingBodyStr<str> ) - A tuple of the created element and the remaining portion to parse

Data descriptors inherited from BodyElement:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
parseBodyStringIntoBodyElements(bodyString)
parseBodyStringIntoBodyElements - Parses the body string of a tag filter expression (between square brackets)
 
    into individual body elements.
 
 
        @param bodyString <str> - A body string of an XPath expression
 
 
        @return list<BodyElement> - A list of matched BodyElement items, in order of appearance.
 
 
        @raises XPathParseError - Failure to parse

 
Data
        __all__ = ('parseBodyStringIntoBodyElements', 'BodyElement', 'BodyElementOperation', 'BodyElementValue', 'BodyElementValueGenerator', 'BodyLevel_Top')