def __bool__(self): if isinstance(self._value, bool): return self._value else: raise_type_error( repr(self), "bool", "bool(yamlobj.data) or bool(yamlobj.text)" )
def __bool__(self): if isinstance(self._value, bool): return self._value else: raise_type_error( repr(self), "bool", "bool(yamlobj.data) or bool(yamlobj.text)" )
def __str__(self): if not self.is_scalar(): raise TypeError( "Cannot cast mapping/sequence '{0}' to string".format( repr(self._value))) elif type(self._value) in (unicode, str, int, float, decimal.Decimal): return unicode(self._value) else: raise_type_error(repr(self), "str", "str(yamlobj.data) or str(yamlobj.text)")
def __str__(self): if type(self._value) in (unicode, int, float, decimal.Decimal): return unicode(self._value) elif isinstance(self._value, CommentedMap) or isinstance(self._value, CommentedSeq): raise TypeError( "Cannot cast mapping/sequence '{0}' to string".format(repr(self._value)) ) else: raise_type_error( repr(self), "str", "str(yamlobj.value) or str(yamlobj.text)" )
def __str__(self): if not self.is_scalar(): raise TypeError( "Cannot cast mapping/sequence '{0}' to string".format(repr(self._value)) ) elif type(self._value) in (unicode, str, int, float, decimal.Decimal): return unicode(self._value) else: raise_type_error( repr(self), "str", "str(yamlobj.data) or str(yamlobj.text)" )