@@ -55,7 +55,7 @@ def __init__(self, filename=None, encoding='utf-8'):
5555
5656 @param filename <str> - Optional filename to parse. Otherwise use parseFile or parseStr methods.
5757 @param encoding <str> - Specifies the document encoding. Default utf-8
58-
58+
5959 '''
6060 HTMLParser .__init__ (self )
6161 # Do not automatically convert charrefs in python3
@@ -111,8 +111,8 @@ def _hasTagInParentLine(self, tag, root):
111111 return self ._hasTagInParentLine (tag .parentNode , root )
112112
113113 def _handleRootArg (self , root ):
114- # Check if tag is string of root and apply to real root.
115- # If real root is unparsed: raise an error.
114+ # Check if tag is string of root and apply to real root.
115+ # If real root is unparsed: raise an error.
116116 # Otherwise: return passed arg.
117117 # Return is tuple (root, isRoot)
118118 if root == 'root' or root == self .root :
@@ -286,8 +286,8 @@ def setRoot(self, root):
286286 def getElementsByTagName (self , tagName , root = 'root' ):
287287 '''
288288 getElementsByTagName - Searches and returns all elements with a specific tag name.
289-
290- @param tagName <lowercase str> - A lowercase string of the tag name.
289+
290+ @param tagName <lowercase str> - A lowercase string of the tag name.
291291 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
292292 '''
293293 (root , isFromRoot ) = self ._handleRootArg (root )
@@ -310,7 +310,7 @@ def getElementsByTagName(self, tagName, root='root'):
310310 def getElementsByName (self , name , root = 'root' ):
311311 '''
312312 getElementsByName - Searches and returns all elements with a specific name.
313-
313+
314314 @param name <str> - A string of the name attribute
315315 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed tree will be used.
316316 '''
@@ -334,7 +334,7 @@ def getElementsByName(self, name, root='root'):
334334 def getElementById (self , _id , root = 'root' ):
335335 '''
336336 getElementById - Searches and returns the first (should only be one) element with the given ID.
337-
337+
338338 @param id <str> - A string of the id attribute.
339339 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed tree will be used.
340340 '''
@@ -358,7 +358,7 @@ def getElementById(self, _id, root='root'):
358358 def getElementsByClassName (self , className , root = 'root' ):
359359 '''
360360 getElementsByClassName - Searches and returns all elements containing a given class name.
361-
361+
362362 @param className <str> - A one-word class name
363363 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root' [default], the root of the parsed tree will be used.
364364 '''
@@ -382,7 +382,7 @@ def getElementsByClassName(self, className, root='root'):
382382 def getElementsByAttr (self , attrName , attrValue , root = 'root' ):
383383 '''
384384 getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. This is always a full scan.
385-
385+
386386 @param attrName <lowercase str> - A lowercase attribute name
387387 @param attrValue <str> - Expected value of attribute
388388 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
@@ -409,7 +409,7 @@ def getElementsWithAttrValues(self, attrName, attrValues, root='root'):
409409 getElementsWithAttrValues - Returns elements with an attribute, named by #attrName contains one of the values in the list, #values
410410
411411 @param attrName <lowercase str> - A lowercase attribute name
412- @param attrValues set<str> - A set of all valid values.
412+ @param attrValues set<str> - A set of all valid values.
413413
414414
415415 @return - TagCollection of all matching elements
@@ -419,7 +419,7 @@ def getElementsWithAttrValues(self, attrName, attrValues, root='root'):
419419
420420 if type (attrValues ) != set :
421421 attrValues = set (attrValues )
422-
422+
423423 return root .getElementsWithAttrValues (attrName , attrValues )
424424
425425
@@ -555,7 +555,7 @@ def filter(self, **kwargs):
555555
556556 Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
557557 without '--no-deps' flag.)
558-
558+
559559 For alternative without QueryableList,
560560 consider #AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
561561
@@ -587,7 +587,7 @@ def filterOr(self, **kwargs):
587587
588588 Requires the QueryableList module to be installed (i.e. AdvancedHTMLParser was installed
589589 without '--no-deps' flag.)
590-
590+
591591 For alternative, consider AdvancedHTMLParser.AdvancedHTMLParser.find method or the getElement* methods
592592
593593 @return TagCollection<AdvancedTag>
@@ -604,7 +604,7 @@ def filterOr(self, **kwargs):
604604 def find (self , ** kwargs ):
605605 '''
606606 find - Perform a search of elements using attributes as keys and potential values as values
607-
607+
608608 (i.e. parser.find(name='blah', tagname='span') will return all elements in this document
609609 with the name "blah" of the tag type "span" )
610610
@@ -810,7 +810,7 @@ def getFormattedHTML(self, indent=' '):
810810 with a pretty-printed version
811811
812812 @param indent - space/tab/newline of each level of indent, or integer for how many spaces per level
813-
813+
814814 @return - <str> Formatted html
815815
816816 @see getHTML - Get HTML with original whitespace
@@ -862,7 +862,7 @@ def feed(self, contents):
862862 def parseFile (self , filename ):
863863 '''
864864 parseFile - Parses a file and creates the DOM tree and indexes
865-
865+
866866 @param filename <str/file> - A string to a filename or a file object. If file object, it will not be closed, you must close.
867867 '''
868868 self .reset ()
@@ -921,7 +921,7 @@ def createElementFromHTML(cls, html, encoding='utf-8'):
921921
922922 Also, if you are just appending to an existing tag, use AdvancedTag.appendInnerHTML
923923 '''
924-
924+
925925 parser = cls (encoding = encoding )
926926
927927 html = stripIEConditionals (html )
@@ -971,7 +971,7 @@ def createElementsFromHTML(cls, html, encoding='utf-8'):
971971 @classmethod
972972 def createBlocksFromHTML (cls , html , encoding = 'utf-8' ):
973973 '''
974- createBlocksFromHTML - Returns the root level node (unless multiple nodes), and
974+ createBlocksFromHTML - Returns the root level node (unless multiple nodes), and
975975 a list of "blocks" added (text and nodes).
976976
977977 @return list< str/AdvancedTag > - List of blocks created. May be strings (text nodes) or AdvancedTag (tags)
@@ -983,7 +983,7 @@ def createBlocksFromHTML(cls, html, encoding='utf-8'):
983983
984984 If True, block is a tag, otherwise, it is a text node
985985 '''
986-
986+
987987 parser = cls (encoding = encoding )
988988
989989 parser .parseStr (html )
@@ -1015,7 +1015,7 @@ def __init__(self, filename=None, encoding='utf-8', indexIDs=True, indexNames=Tr
10151015 @param indexTagNames <bool> - True to create an index for tag names. <default True>
10161016
10171017 For indexing other attributes, see the more generic addIndexOnAttribute
1018-
1018+
10191019 '''
10201020 self .indexFunctions = []
10211021 self .otherAttributeIndexFunctions = {}
@@ -1061,7 +1061,7 @@ def _indexID(self, tag):
10611061 _id = tag .getAttribute ('id' )
10621062 if _id :
10631063 self ._idMap [_id ] = tag
1064-
1064+
10651065 def _indexName (self , tag ):
10661066 name = tag .getAttribute ('name' )
10671067 if name :
@@ -1113,7 +1113,7 @@ def setRoot(self, root):
11131113 self .reindex ()
11141114
11151115##########################################################
1116- # Public
1116+ # Public
11171117##########################################################
11181118
11191119 # This should be called if you modify a parsed tree at an element level, then search it.
@@ -1151,7 +1151,7 @@ def addIndexOnAttribute(self, attributeName):
11511151 '''
11521152 addIndexOnAttribute - Add an index for an arbitrary attribute. This will be used by the getElementsByAttr function.
11531153 You should do this prior to parsing, or call reindex. Otherwise it will be blank. "name" and "id" will have no effect.
1154-
1154+
11551155 @param attributeName <lowercase str> - An attribute name. Will be lowercased.
11561156 '''
11571157 attributeName = attributeName .lower ()
@@ -1178,13 +1178,13 @@ def removeIndexOnAttribute(self, attributeName):
11781178 del self .otherAttributeIndexFunctions [attributeName ]
11791179 if attributeName in self ._otherAttributeIndexes :
11801180 del self ._otherAttributeIndexes [attributeName ]
1181-
1181+
11821182
11831183 def getElementsByTagName (self , tagName , root = 'root' , useIndex = True ):
11841184 '''
11851185 getElementsByTagName - Searches and returns all elements with a specific tag name.
1186-
1187- @param tagName <lowercase str> - A lowercase string of the tag name.
1186+
1187+ @param tagName <lowercase str> - A lowercase string of the tag name.
11881188 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
11891189 @param useIndex - If True [default] and tag names are set to be indexed [default, see constructor], only the index will be used. If False, all tags
11901190 will be searched.
@@ -1205,7 +1205,7 @@ def getElementsByTagName(self, tagName, root='root', useIndex=True):
12051205 def getElementsByName (self , name , root = 'root' , useIndex = True ):
12061206 '''
12071207 getElementsByName - Searches and returns all elements with a specific name.
1208-
1208+
12091209 @param name <str> - A string of the name attribute
12101210 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
12111211 @param useIndex <bool> If useIndex is True and names are indexed [see constructor] only the index will be used. Otherwise a full search is performed.
@@ -1229,7 +1229,7 @@ def getElementsByName(self, name, root='root', useIndex=True):
12291229 def getElementById (self , _id , root = 'root' , useIndex = True ):
12301230 '''
12311231 getElementById - Searches and returns the first (should only be one) element with the given ID.
1232-
1232+
12331233 @param id <str> - A string of the id attribute.
12341234 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
12351235 @param useIndex <bool> If useIndex is True and ids are indexed [see constructor] only the index will be used. Otherwise a full search is performed.
@@ -1244,7 +1244,7 @@ def getElementById(self, _id, root='root', useIndex=True):
12441244
12451245 if self ._hasTagInParentLine (element , root ) is False :
12461246 element = None
1247-
1247+
12481248 return element
12491249
12501250
@@ -1254,7 +1254,7 @@ def getElementById(self, _id, root='root', useIndex=True):
12541254 def getElementsByClassName (self , className , root = 'root' , useIndex = True ):
12551255 '''
12561256 getElementsByClassName - Searches and returns all elements containing a given class name.
1257-
1257+
12581258 @param className <str> - A one-word class name
12591259 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
12601260 @param useIndex <bool> If useIndex is True and class names are indexed [see constructor] only the index will be used. Otherwise a full search is performed.
@@ -1278,7 +1278,7 @@ def getElementsByAttr(self, attrName, attrValue, root='root', useIndex=True):
12781278 '''
12791279 getElementsByAttr - Searches the full tree for elements with a given attribute name and value combination. If you want multiple potential values, see getElementsWithAttrValues
12801280 If you want an index on a random attribute, use the addIndexOnAttribute function.
1281-
1281+
12821282 @param attrName <lowercase str> - A lowercase attribute name
12831283 @param attrValue <str> - Expected value of attribute
12841284 @param root <AdvancedTag/'root'> - Search starting at a specific node, if provided. if string 'root', the root of the parsed tree will be used.
@@ -1295,7 +1295,7 @@ def getElementsByAttr(self, attrName, attrValue, root='root', useIndex=True):
12951295 elements = [x for x in elements if _hasTagInParentLine (x , root )]
12961296
12971297 return TagCollection (elements )
1298-
1298+
12991299 return AdvancedHTMLParser .getElementsByAttr (self , attrName , attrValue , root )
13001300
13011301
0 commit comments