Strings, Numbers and Booleans¶
Strings¶
-
class
String(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.ScalarA 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
stripis true, leading and trailing whitespace will be removed.
-
serialize(value)¶ Return a text representation.
- Returns
a Unicode value or
u''if value isNone
If
stripis 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.NumberElement type for Python’s int.
-
type_¶ alias of
builtins.int
-
format= '%i'¶ u'%i'
-
-
class
Long(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.NumberElement type for Python’s long.
-
type_¶ alias of
builtins.int
-
format= '%i'¶ u'%i'
-
-
class
Float(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.NumberElement type for Python’s float.
-
type_¶ alias of
builtins.float
-
format= '%f'¶ u'%f'
-
-
class
Decimal(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.NumberElement type for Python’s Decimal.
-
type_¶ alias of
decimal.Decimal
-
format= '%f'¶ u'%f'
-
Booleans¶
-
class
Boolean(value=Unspecified, **kw)¶ Bases:
flatland.schema.scalars.ScalarElement 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
boolorNone
If value is text, returns
Trueif the value is intrue_synonyms,Falseif infalse_synonymsandNoneotherwise.For non-text values, equivalent to
bool(value).
-
serialize(value)¶ Convert
bool(value)to a canonical text representation.- Returns
either
self.trueorself.false.
-