text stringlengths 81 112k |
|---|
lastChild - property, Get the last child block, text or tag
@return <str/AdvancedTag/None> - The last child block, or None if no child blocks
def lastChild(self):
'''
lastChild - property, Get the last child block, text or tag
@return <str/AdvancedTag/None> - The l... |
nextSibling - Returns the next sibling. This is the child following this node in the parent's list of children.
This could be text or an element. use nextSiblingElement to ensure element
@return <None/str/AdvancedTag> - None if there are no nodes (text or tag) in the parent after t... |
nextElementSibling - Returns the next sibling that is an element.
This is the tag node following this node in the parent's list of children
@return <None/AdvancedTag> - None if there are no children (tag) in the parent after this node,
... |
previousSibling - Returns the previous sibling. This would be the previous node (text or tag) in the parent's list
This could be text or an element. use previousSiblingElement to ensure element
@return <None/str/AdvancedTag> - None if there are no nodes (text or tag) in th... |
previousElementSibling - Returns the previous sibling that is an element.
This is the previous tag node in the parent's list of children
@return <None/AdvancedTag> - None if there are no children (tag) in the parent before this node,
... |
tagBlocks - Property.
Returns all the blocks which are direct children of this node, where that block is a tag (not text)
NOTE: This is similar to .children , and you should probably use .children instead except within this class itself
@return list<AdvancedTag... |
getBlocksTags - Returns a list of tuples referencing the blocks which are direct children of this node, and the block is an AdvancedTag.
The tuples are ( block, blockIdx ) where "blockIdx" is the index of self.blocks wherein the tag resides.
@return list< tuple(block, blockIdx) > - A l... |
textBlocks - Property.
Returns all the blocks which are direct children of this node, where that block is a text (not a tag)
@return list<AdvancedTag> - A list of direct children which are text.
def textBlocks(self):
'''
textBlocks - Property.
... |
textContent - property, gets the text of this node and all inner nodes.
Use .innerText for just this node's text
@return <str> - The text of all nodes at this level or lower
def textContent(self):
'''
textContent - property, gets the text of this node and all inner n... |
containsUid - Check if the uid (unique internal ID) appears anywhere as a direct child to this node, or the node itself.
@param uid <uuid.UUID> - uuid to check
@return <bool> - True if #uid is this node's uid, or is the uid of any children at any level down
def containsUid(self, uid):
... |
getAllChildNodes - Gets all the children, and their children,
and their children, and so on, all the way to the end as a TagCollection.
Use .childNodes for a regular list
@return TagCollection<AdvancedTag> - A TagCollection of all children (and their children ... |
getAllChildNodeUids - Returns all the unique internal IDs for all children, and there children,
so on and so forth until the end.
For performing "contains node" kind of logic, this is more efficent than copying the entire nodeset
@return set<uuid.UUID> A set of uuid objects
d... |
getAllNodeUids - Returns all the unique internal IDs from getAllChildNodeUids, but also includes this tag's uid
@return set<uuid.UUID> A set of uuid objects
def getAllNodeUids(self):
'''
getAllNodeUids - Returns all the unique internal IDs from getAllChildNodeUids, but also includes th... |
getPeers - Get elements who share a parent with this element
@return - TagCollection of elements
def getPeers(self):
'''
getPeers - Get elements who share a parent with this element
@return - TagCollection of elements
'''
parentNode = self.parentNode
... |
getStartTag - Returns the start tag represented as HTML
@return - String of start tag with attributes
def getStartTag(self):
'''
getStartTag - Returns the start tag represented as HTML
@return - String of start tag with attributes
'''
attributeStrings = []
... |
getEndTag - returns the end tag representation as HTML string
@return - String of end tag
def getEndTag(self):
'''
getEndTag - returns the end tag representation as HTML string
@return - String of end tag
'''
# If this is a self-closing tag, we have no end ... |
innerHTML - Returns an HTML string of the inner contents of this tag, including children.
@return - String of inner contents HTML
def innerHTML(self):
'''
innerHTML - Returns an HTML string of the inner contents of this tag, including children.
@return - String of inner co... |
getAttribute - Gets an attribute on this tag. Be wary using this for classname, maybe use addClass/removeClass. Attribute names are all lowercase.
@return - The attribute value, or None if none exists.
def getAttribute(self, attrName, defaultValue=None):
'''
getAttribute - Gets an a... |
getAttributesList - Get a copy of all attributes as a list of tuples (name, value)
ALL values are converted to string and copied, so modifications will not affect the original attributes.
If you want types like "style" to work as before, you'll need to recreate those elements (like StyleA... |
getAttributesDict - Get a copy of all attributes as a dict map of name -> value
ALL values are converted to string and copied, so modifications will not affect the original attributes.
If you want types like "style" to work as before, you'll need to recreate those elements (like StyleAttr... |
hasAttribute - Checks for the existance of an attribute. Attribute names are all lowercase.
@param attrName <str> - The attribute name
@return <bool> - True or False if attribute exists by that name
def hasAttribute(self, attrName):
'''
hasAttrib... |
removeAttribute - Removes an attribute, by name.
@param attrName <str> - The attribute name
def removeAttribute(self, attrName):
'''
removeAttribute - Removes an attribute, by name.
@param attrName <str> - The attribute name
'''
att... |
addClass - append a class name to the end of the "class" attribute, if not present
@param className <str> - The name of the class to add
def addClass(self, className):
'''
addClass - append a class name to the end of the "class" attribute, if not present
@param cla... |
removeClass - remove a class name if present. Returns the class name if removed, otherwise None.
@param className <str> - The name of the class to remove
@return <str> - The class name removed if one was removed, otherwise None if #className wasn't present
def removeClass(self, class... |
getStyleDict - Gets a dictionary of style attribute/value pairs.
@return - OrderedDict of "style" attribute.
def getStyleDict(self):
'''
getStyleDict - Gets a dictionary of style attribute/value pairs.
@return - OrderedDict of "style" attribute.
'''
# TODO... |
setStyle - Sets a style param. Example: "display", "block"
If you need to set many styles on an element, use setStyles instead.
It takes a dictionary of attribute, value pairs and applies it all in one go (faster)
To remove a style, set its value to empty string.
... |
setStyles - Sets one or more style params.
This all happens in one shot, so it is much much faster than calling setStyle for every value.
To remove a style, set its value to empty string.
When all styles are removed, the "style" attribute will be nullified.
... |
getElementById - Search children of this tag for a tag containing an id
@param _id - String of id
@return - AdvancedTag or None
def getElementById(self, _id):
'''
getElementById - Search children of this tag for a tag containing an id
@param _id - String of id... |
getElementsByAttr - Search children of this tag for tags with an attribute name/value pair
@param attrName - Attribute name (lowercase)
@param attrValue - Attribute value
@return - TagCollection of matching elements
def getElementsByAttr(self, attrName, attrValue):
'''
... |
getElementsByClassName - Search children of this tag for tags containing a given class name
@param className - Class name
@return - TagCollection of matching elements
def getElementsByClassName(self, className):
'''
getElementsByClassName - Search children of this tag for ... |
getElementsWithAttrValues - Search children of this tag for tags with an attribute name and one of several values
@param attrName <lowercase str> - Attribute name (lowercase)
@param attrValues set<str> - set of acceptable attribute values
@return - TagCollection of matching element... |
getElementsCustomFilter - Searches children of this tag for those matching a provided user function
@param filterFunc <function> - A function or lambda expression that should return "True" if the passed node matches criteria.
@return - TagCollection of matching results
@see getFir... |
getFirstElementCustomFilter - Gets the first element which matches a given filter func.
Scans first child, to the bottom, then next child to the bottom, etc. Does not include "self" node.
@param filterFunc <function> - A function or lambda expression that should return "True" if the passed... |
getParentElementCustomFilter - Runs through parent on up to document root, returning the
first tag which filterFunc(tag) returns True.
@param filterFunc <function/lambda> - A function or lambda expression that should return "True" if the passed node matche... |
getPeersCustomFilter - Get elements who share a parent with this element and also pass a custom filter check
@param filterFunc <lambda/function> - Passed in an element, and returns True if it should be treated as a match, otherwise False.
@return <TagCollection> - Resulting peers, or N... |
getPeersByAttr - Gets peers (elements on same level) which match an attribute/value combination.
@param attrName - Name of attribute
@param attrValue - Value that must match
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
def... |
getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName
are in the list of possible vaues #attrValues
@param attrName - Name of attribute
@param attrValues - List of possible values which will match
@return - None if no paren... |
getPeersByName - Gets peers (elements on same level) with a given name
@param name - Name to match
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
def getPeersByName(self, name):
'''
getPeersByName - Gets peers (eleme... |
getPeersByClassName - Gets peers (elements on same level) with a given class name
@param className - classname must contain this name
@return - None if no parent element (error condition), otherwise a TagCollection of peers that matched.
def getPeersByClassName(self, className):
'''
... |
isTagEqual - Compare if a tag contains the same tag name and attributes as another tag,
i.e. if everything between < and > parts of this tag are the same.
Does NOT compare children, etc. Does NOT compare if these are the same exact tag in the html (use regular == operator for that)
... |
append - Append an item to this tag collection
@param tag - an AdvancedTag
def append(self, tag):
'''
append - Append an item to this tag collection
@param tag - an AdvancedTag
'''
list.append(self, tag)
self.uids.add(tag.uid) |
remove - Remove an item from this tag collection
@param toRemove - an AdvancedTag
def remove(self, toRemove):
'''
remove - Remove an item from this tag collection
@param toRemove - an AdvancedTag
'''
list.remove(self, toRemove)
self.uids.remove(toRe... |
filterCollection - Filters only the immediate objects contained within this Collection against a function, not including any children
@param filterFunc <function> - A function or lambda expression that returns True to have that element match
@return TagCollection<AdvancedTag>
def filterCollec... |
getElementsByTagName - Gets elements within this collection having a specific tag name
@param tagName - String of tag name
@return - TagCollection of unique elements within this collection with given tag name
def getElementsByTagName(self, tagName):
'''
getElementsByTagNam... |
getElementsByName - Get elements within this collection having a specific name
@param name - String of "name" attribute
@return - TagCollection of unique elements within this collection with given "name"
def getElementsByName(self, name):
'''
getElementsByName - Get elemen... |
getElementsByClassName - Get elements within this collection containing a specific class name
@param className - A single class name
@return - TagCollection of unique elements within this collection tagged with a specific class name
def getElementsByClassName(self, className):
'''
... |
getElementById - Gets an element within this collection by id
@param _id - string of "id" attribute
@return - a single tag matching the id, or None if none found
def getElementById(self, _id):
'''
getElementById - Gets an element within this collection by id
@... |
getElementsByAttr - Get elements within this collection posessing a given attribute/value pair
@param attr - Attribute name (lowercase)
@param value - Matching value
@return - TagCollection of all elements matching name/value
def getElementsByAttr(self, attr, value):
'''
... |
getElementsWithAttrValues - Get elements within this collection possessing an attribute name matching one of several values
@param attr <lowercase str> - Attribute name (lowerase)
@param values set<str> - Set of possible matching values
@return - TagCollection of all elements match... |
getElementsCustomFilter - Get elements within this collection that match a user-provided function.
@param filterFunc <function> - A function that returns True if the element matches criteria
@return - TagCollection of all elements that matched criteria
def getElementsCustomFilter(self, filter... |
getAllNodes - Gets all the nodes, and all their children for every node within this collection
def getAllNodes(self):
'''
getAllNodes - Gets all the nodes, and all their children for every node within this collection
'''
ret = TagCollection()
for tag in self:
re... |
getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on..
@return set<uuid.UUID>
def getAllNodeUids(self):
'''
getAllNodeUids - Gets all the internal uids of all nodes, their children, and all their children so on..
@retur... |
contains - Check if #em occurs within any of the elements within this list, as themselves or as a child, any
number of levels down.
To check if JUST an element is contained within this list directly, use the "in" operator.
@param em <AdvancedTag> - Element of inte... |
containsUid - Check if #uid is the uid (unique internal identifier) of any of the elements within this list,
as themselves or as a child, any number of levels down.
@param uid <uuid.UUID> - uuid of interest
@return <bool> - True if contained, otherwise False
def cont... |
filterAll aka filterAllAnd - Perform a filter operation on ALL nodes in this collection and all their children.
Results must match ALL the filter criteria. for ANY, use the *Or methods
For just the nodes in this collection, use "filter" or "filterAnd" on a TagCollection
For specia... |
filterAllOr - Perform a filter operation on ALL nodes in this collection and all their children.
Results must match ANY the filter criteria. for ALL, use the *And methods
For just the nodes in this collection, use "filterOr" on a TagCollection
For special filter keys, @see #Advanc... |
handle_starttag - Internal for parsing
def handle_starttag(self, tagName, attributeList, isSelfClosing=False):
'''
handle_starttag - Internal for parsing
'''
tagName = tagName.lower()
inTag = self._inTag
if isSelfClosing is False and tagName in IMPLICIT_SELF_CLOSING... |
handle_endtag - Internal for parsing
def handle_endtag(self, tagName):
'''
handle_endtag - Internal for parsing
'''
inTag = self._inTag
try:
# Handle closing tags which should have been closed but weren't
foundIt = False
for i in range(len... |
handle_data - Internal for parsing
def handle_data(self, data):
'''
handle_data - Internal for parsing
'''
if data:
inTag = self._inTag
if len(inTag) > 0:
if inTag[-1].tagName not in PRESERVE_CONTENTS_TAGS:
data = data.repl... |
getStartTag - Override the end-spacing rules
@see AdvancedTag.getStartTag
def getStartTag(self, *args, **kwargs):
'''
getStartTag - Override the end-spacing rules
@see AdvancedTag.getStartTag
'''
ret = AdvancedTag.getStartTag(self, *args, **kwargs)
... |
stripIEConditionals - Strips Internet Explorer conditional statements.
@param contents <str> - Contents String
@param addHtmlIfMissing <bool> - Since these normally encompass the "html" element, optionally add it back if missing.
def stripIEConditionals(contents, addHtmlIfMissing=True):
'''
... |
addStartTag - Safetly add a start tag to the document, taking into account the DOCTYPE
@param contents <str> - Contents
@param startTag <str> - Fully formed tag, i.e. <html>
def addStartTag(contents, startTag):
'''
addStartTag - Safetly add a start tag to the document, taking into account ... |
Internal for parsing
def handle_endtag(self, tagName):
'''
Internal for parsing
'''
inTag = self._inTag
if len(inTag) == 0:
# Attempted to close, but no open tags
raise InvalidCloseException(tagName, [])
foundIt = False
i = len(inTag)... |
convertToBooleanString - Converts a value to either a string of "true" or "false"
@param val <int/str/bool> - Value
def convertToBooleanString(val=None):
'''
convertToBooleanString - Converts a value to either a string of "true" or "false"
@param val <int/str/bool> - Value
'''... |
convertBooleanStringToBoolean - Convert from a boolean attribute (string "true" / "false" ) into a booelan
def convertBooleanStringToBoolean(val=None):
'''
convertBooleanStringToBoolean - Convert from a boolean attribute (string "true" / "false" ) into a booelan
'''
if not val:
return False... |
convertToPositiveInt - Convert to a positive integer, and if invalid use a given value
def convertToPositiveInt(val=None, invalidDefault=0):
'''
convertToPositiveInt - Convert to a positive integer, and if invalid use a given value
'''
if val is None:
return invalidDefault
try:
... |
_handleInvalid - Common code for raising / returning an invalid value
@param invalidDefault <None/str/Exception> - The value to return if "val" is not empty string/None
and "val" is not in #possibleValues
If instantiated Excep... |
convertPossibleValues - Convert input value to one of several possible values,
with a default for invalid entries
@param val <None/str> - The input value
@param possibleValues list<str> - A list of possible values
@param invalidDefa... |
converToIntRange - Convert input value to an integer within a certain range
@param val <None/str/int/float> - The input value
@param minValue <None/int> - The minimum value (inclusive), or None if no minimum
@param maxValue <None/int> - The maximum value (inclusive), o... |
_setTag - INTERNAL METHOD. Associated a given AdvancedTag to this attributes dict.
If bool(#tag) is True, will set the weakref to that tag.
Otherwise, will clear the reference
@param tag <AdvancedTag/None> - Either the AdvancedTag to associate, or... |
_handleClassAttr - Hack to ensure "class" and "style" show up in attributes when classes are set,
and doesn't when no classes are present on associated tag.
TODO: I don't like this hack.
def _handleClassAttr(self):
'''
_handleClassAttr - Hack to ensure "class" and "... |
get - Gets an attribute by key with the chance to provide a default value
@param key <str> - The key to query
@param default <Anything> Default None - The value to return if key is not found
@return - The value of attribute at #key, or #default if not present.
def get(se... |
_direct_set - INTERNAL USE ONLY!!!!
Directly sets a value on the underlying dict, without running through the setitem logic
def _direct_set(self, key, value):
'''
_direct_set - INTERNAL USE ONLY!!!!
Directly sets a value on the underlying dict, without running thro... |
setTag - Set the tag association for this style.
This will handle the underlying weakref to the tag.
Call setTag(None) to clear the association, otherwise setTag(tag) to associate this style to that tag.
@param tag <AdvancedTag/None> - The new association. If ... |
_ensureHtmlAttribute - INTERNAL METHOD.
Ensure the "style" attribute is present in the html attributes when
is has a value, and absent when it does not.
This requires special linkage.
def _ensureHtmlAttribute(self):
'''... |
setProperty - Set a style property to a value.
NOTE: To remove a style, use a value of empty string, or None
@param name <str> - The style name.
NOTE: The dash names are expected here, whereas dot-access expects the camel case names.
Example... |
dashNameToCamelCase - Converts a "dash name" (like padding-top) to its camel-case name ( like "paddingTop" )
@param dashName <str> - A name containing dashes
NOTE: This method is currently unused, but may be used in the future. kept for completeness.
@return <str> - The camel-... |
camelCaseToDashName - Convert a camel case name to a dash-name (like paddingTop to padding-top)
@param camelCase <str> - A camel-case string
@return <str> - A dash-name
def camelCaseToDashName(camelCase):
'''
camelCaseToDashName - Convert a camel case name to a dash-name (... |
getStyleDict - Gets a dictionary of style attribute/value pairs.
NOTE: dash-names (like padding-top) are used here
@return - OrderedDict of "style" attribute.
def styleToDict(styleStr):
'''
getStyleDict - Gets a dictionary of style attribute/value pairs.
N... |
_asStr - Get the string representation of this style
@return <str> - A string representation of this style (semicolon separated, key: value format)
def _asStr(self):
'''
_asStr - Get the string representation of this style
@return <str> - A string representation of thi... |
_special_value_rows - Handle "rows" special attribute, which differs if tagName is a textarea or frameset
def _special_value_rows(em):
'''
_special_value_rows - Handle "rows" special attribute, which differs if tagName is a textarea or frameset
'''
if em.tagName == 'textarea':
return conver... |
_special_value_cols - Handle "cols" special attribute, which differs if tagName is a textarea or frameset
def _special_value_cols(em):
'''
_special_value_cols - Handle "cols" special attribute, which differs if tagName is a textarea or frameset
'''
if em.tagName == 'textarea':
return conver... |
handle "autocomplete" property, which has different behaviour for form vs input"
def _special_value_autocomplete(em):
'''
handle "autocomplete" property, which has different behaviour for form vs input"
'''
if em.tagName == 'form':
return convertPossibleValues(em.getAttribute('autocomplete'... |
handle "size" property, which has different behaviour for input vs everything else
def _special_value_size(em):
'''
handle "size" property, which has different behaviour for input vs everything else
'''
if em.tagName == 'input':
# TODO: "size" on an input is implemented very weirdly. Negati... |
_special_value_maxLength - Handle the special "maxLength" property
@param em <AdvancedTag> - The tag element
@param newValue - Default NOT_PROVIDED, if provided will use that value instead of the
current .getAttribute value on the tag. This is because this method can be used f... |
Converts a value into a corresponding data object.
For files, this looks up a file DataObject by name, uuid, and/or md5.
For other types, it creates a new DataObject.
def get_by_value(cls, value, type):
""" Converts a value into a corresponding data object.
For files, this looks up a ... |
Look up a file DataObject by name, uuid, and/or md5.
def _get_file_by_value(cls, value):
"""Look up a file DataObject by name, uuid, and/or md5.
"""
# Ignore any FileResource with no DataObject. This is a typical state
# for a deleted file that has not yet been cleaned up.
query... |
Create a path for a given file, in such a way
that files end up being organized and browsable by run
def _get_run_breadcrumbs(cls, source_type, data_object, task_attempt):
"""Create a path for a given file, in such a way
that files end up being organized and browsable by run
"""
... |
Find objects that match the identifier of form {name}@{ID}, {name},
or @{ID}, where ID may be truncated
def filter_by_name_or_id_or_tag(self, query_string, queryset = None):
"""Find objects that match the identifier of form {name}@{ID}, {name},
or @{ID}, where ID may be truncated
"""
... |
This save method protects against two processesses concurrently modifying
the same object. Normally the second save would silently overwrite the
changes from the first. Instead we raise a ConcurrentModificationError.
def save(self, *args, **kwargs):
"""
This save method protects against... |
If the object is being edited by other processes,
save may fail due to concurrent modification.
This method recovers and retries the edit.
assignments is a dict of {attribute: value}
def setattrs_and_save_with_retries(self, assignments, max_retries=5):
"""
If the object is bein... |
This method implements retries for object deletion.
def delete(self, *args, **kwargs):
"""
This method implements retries for object deletion.
"""
count = 0
max_retries=3
while True:
try:
return super(BaseModel, self).delete(*args, **kwargs)
... |
Checks server.ini for server type.
def get_server_type():
"""Checks server.ini for server type."""
server_location_file = os.path.expanduser(SERVER_LOCATION_FILE)
if not os.path.exists(server_location_file):
raise Exception(
"%s not found. Please run 'loom server set "
"<ser... |
Set file_data_object.file_resource.upload_status
def _set_upload_status(self, file_data_object, upload_status):
""" Set file_data_object.file_resource.upload_status
"""
uuid = file_data_object['uuid']
return self.connection.update_data_object(
uuid,
{'uuid': uuid... |
Anywhere in "template" that refers to a data object but does not
give a specific UUID, if a matching file can be found in "file_dependencies",
we will change the data object reference to use that UUID. That way templates
have a preference to connect to files nested under their ".dependencies" o... |
Converts command line args into a list of template inputs
def _get_inputs(self):
"""Converts command line args into a list of template inputs
"""
# Convert file inputs to a dict, to make it easier to override
# them with commandline inputs
file_inputs = self._get_file_inputs()
... |
e.g., convert "[[a,b,c],[d,e],[f,g]]"
into [["a","b","c"],["d","e"],["f","g"]]
def _parse_string_to_nested_lists(self, value):
"""e.g., convert "[[a,b,c],[d,e],[f,g]]"
into [["a","b","c"],["d","e"],["f","g"]]
"""
if not re.match(r'\[.*\]', value.strip()):
if '[' in v... |
Converts command line args into a list of template inputs
def _get_inputs(self, old_inputs):
"""Converts command line args into a list of template inputs
"""
# Convert inputs to dict to facilitate overriding by channel name
# Also, drop DataNode ID and keep only contents.
input_... |
This is a standard method called indirectly by calling
'save' on the serializer.
This method expects the 'parent_field' and 'parent_instance' to
be included in the Serializer context.
def create(self, validated_data):
""" This is a standard method called indirectly by calling
'... |
Suppress warning about untrusted SSL certificate.
def disable_insecure_request_warning():
"""Suppress warning about untrusted SSL certificate."""
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.