Skip to content

bpo-13743: Add some documentation strings to xml.dom.minidom #16355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Lib/xml/dom/minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,14 @@ def unlink(self):
Node.unlink(self)

def getAttribute(self, attname):
"""Returns the value of the specified attribute.

Returns the value of the element's attribute named attname as
a string. An empty string is returned if the element does not
have such an attribute. Note that an empty string may also be
returned as an explicitly given attribute value, use the
hasAttribute method to distinguish these two cases.
"""
if self._attrs is None:
return ""
try:
Expand Down Expand Up @@ -828,6 +836,11 @@ def removeAttributeNode(self, node):
removeAttributeNodeNS = removeAttributeNode

def hasAttribute(self, name):
"""Checks whether the element has an attribute with the specified name.

Returns True if the element has an attribute with the specified name.
Otherwise, returns False.
"""
if self._attrs is None:
return False
return name in self._attrs
Expand All @@ -838,6 +851,11 @@ def hasAttributeNS(self, namespaceURI, localName):
return (namespaceURI, localName) in self._attrsNS

def getElementsByTagName(self, name):
"""Returns all descendant elements with the given tag name.

Returns the list of all descendant elements (not direct children
only) with the specified tag name.
"""
return _get_elements_by_tagName_helper(self, name, NodeList())

def getElementsByTagNameNS(self, namespaceURI, localName):
Expand All @@ -848,6 +866,11 @@ def __repr__(self):
return "<DOM Element: %s at %#x>" % (self.tagName, id(self))

def writexml(self, writer, indent="", addindent="", newl=""):
"""Write an XML element to a file-like object

Write the element to the writer object that must provide
a write method (e.g. a file or StringIO object).
"""
# indent = current indentation
# addindent = indentation to add to higher levels
# newl = newline string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Some methods within xml.dom.minidom.Element class are now better documented.