示例#1
0
 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)"
         )
示例#2
0
 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)"
         )
示例#3
0
 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)")
示例#4
0
 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)"
         )
示例#5
0
 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)"
         )