Strings, Numbers and Booleans¶
Strings¶
-
class
String
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Scalar
A regular old text string.
-
strip
= True¶ If true, strip leading and trailing whitespace during conversion.
-
adapt
(value)¶ Return a Python representation.
- Returns
a text value or
None
If
strip
is true, leading and trailing whitespace will be removed.
-
serialize
(value)¶ Return a text representation.
- Returns
a Unicode value or
u''
if value isNone
If
strip
is true, leading and trailing whitespace will be removed.
-
property
is_empty
¶ True if the String is missing or has no value.
-
Numbers¶
-
class
Integer
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Number
Element type for Python’s int.
-
type_
¶ alias of
builtins.int
-
format
= '%i'¶ u'%i'
-
-
class
Long
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Number
Element type for Python’s long.
-
type_
¶ alias of
builtins.int
-
format
= '%i'¶ u'%i'
-
-
class
Float
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Number
Element type for Python’s float.
-
type_
¶ alias of
builtins.float
-
format
= '%f'¶ u'%f'
-
-
class
Decimal
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Number
Element type for Python’s Decimal.
-
type_
¶ alias of
decimal.Decimal
-
format
= '%f'¶ u'%f'
-
Booleans¶
-
class
Boolean
(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.Scalar
Element type for Python’s
bool
.-
true
= '1'¶ The text serialization for
True
:u'1'
.
-
true_synonyms
= ('on', 'true', 'True', '1')¶ A sequence of acceptable string equivalents for True.
Defaults to
(u'on', u'true', u'True', u'1')
-
false
= ''¶ The text serialization for
False
:u''
.
-
false_synonyms
= ('off', 'false', 'False', '0', '')¶ A sequence of acceptable string equivalents for False.
Defaults to
(u'off', u'false', u'False', u'0', u'')
-
adapt
(value)¶ Coerce value to
bool
.- Returns
a
bool
orNone
If value is text, returns
True
if the value is intrue_synonyms
,False
if infalse_synonyms
andNone
otherwise.For non-text values, equivalent to
bool(value)
.
-
serialize
(value)¶ Convert
bool(value)
to a canonical text representation.- Returns
either
self.true
orself.false
.
-