MCPcopy Create free account
hub / github.com/PageBot/PageBot / get

Method get

Lib/pagebot/elements/element.py:606–635  ·  view source on GitHub ↗

Answers the element by eId or name. Answers the same selection for default, if the element cannot be found. Answers None if it does not exist. >>> e = Element(name='Parent') >>> e1 = Element(name='Child') >>> i = e.appendElement(e1) >>> # Get child el

(self, eIdOrName, default=None)

Source from the content-addressed store, hash-verified

604 root = property(_get_root)
605
606 def get(self, eIdOrName, default=None):
607 """Answers the element by eId or name. Answers the same selection for
608 default, if the element cannot be found. Answers None if it does not
609 exist.
610
611 >>> e = Element(name='Parent')
612 >>> e1 = Element(name='Child')
613 >>> i = e.appendElement(e1)
614 >>> # Get child element by its name
615 >>> child = e.get('Child')
616 >>> child is e1
617 True
618 >>> # Get child elements by is eId
619 >>> child = e.get(e1.eId)
620 >>> child is e1
621 True
622 >>> # Child has e as parent
623 >>> child.name, child.parent.name
624 ('Child', 'Parent')
625 >>> e.get('OtherName') is None
626 True
627 """
628 if eIdOrName in self._eIds:
629 return self._eIds[eIdOrName]
630 e = self.getElementByName(eIdOrName)
631 if e is not None:
632 return e
633 if default is not None:
634 return self.get(default)
635 return None
636
637 def getElement(self, eId):
638 """Answers the page element, if it has a unique element Id. Answers None

Callers 15

__getitem__Method · 0.95
getElementMethod · 0.45
buildFrameMethod · 0.45
checkStyleArgsMethod · 0.45
_get_xMethod · 0.45
_get_yMethod · 0.45
_get_zMethod · 0.45
_get_angleMethod · 0.45
_get_rxMethod · 0.45
_get_ryMethod · 0.45
_get_rzMethod · 0.45
_get_foldsMethod · 0.45

Calls 1

getElementByNameMethod · 0.95

Tested by

no test coverage detected