def _ReadBoolAttrib(self, xmlElement: ET.Element, attribName: str, defaultValue: Optional[bool] = None) -> bool: """ If the attrib is there we return it if its not there and defaultValue is not None we return the default value. if its not there and defaultValue is None we throw a exception. """ strValue = self._TryReadAttrib(xmlElement, attribName, None) if strValue is not None: return BoolStringHelper.FromString(strValue) elif defaultValue is not None: return defaultValue raise XmlFormatException( "{0} expects a value of either 'true' or 'false' not '{1}'".format( attribName, strValue))
def _TryReadBoolAttrib(self, xmlElement: ET.Element, attribName: str, defaultValue: Optional[bool]) -> Optional[bool]: value = self._TryReadAttrib(xmlElement, attribName, None) if value is None: return defaultValue return BoolStringHelper.TryFromString(value)