Python Objects#
Schema#
Fields#
- class yankee.base.fields.Field(*args, default=None, **kwargs)[source]#
The basic field - performs no type casting
- output_type = typing.Any#
- class yankee.base.fields.String(*args, formatter=None, null_value=None, **kwargs)[source]#
String Field
Always outputs a string value, or None
- Parameters:
formatter (Callable) – a callable for formatting the resulting string. Defaults to a newline-preserving whitespace cleaner
null_value (str) – a string value to indicate that it should be None. Some data sources use a hyphen or other symbol rather than empty value
- class yankee.base.fields.DateTime(*args, dt_format=None, dt_converter=False, **kwargs)[source]#
DateTime Field
Always outputs a datetime.datetime value. The initial value retrieved should be a string, which is then parsed as an isoformatted date. If that parsing fails, it uses dateutil.parser.parse to attempt to retrieve a datetime.
- Parameters:
dt_format (str) – a formatting string from datetime.datetime.strptime to use
dt_converter (callable) – a custom function to parse a date, overriding the default
- deserialize(elem) Optional[datetime.datetime][source]#
- class yankee.base.fields.Date(*args, dt_format=None, dt_converter=False, **kwargs)[source]#
Date Field
Always outputs a datetime.date value. Uses the same args as DateTime
- deserialize(elem) Optional[datetime.date][source]#
- class yankee.base.fields.Boolean(*args, true_value='true', true_func=None, case_sensitive=False, allow_none=True, **kwargs)[source]#
Boolean Field
Always outputs a boolean value (True, or False)
- Parameters:
true_value (str) – a custom string value that should be considered truthy
true_func (Callable) – a custom function that, when executed on the result, should return True or False
case_sensitive (str) – if a true_value is provided, whether it should be considered case sensitive
allow_none (str) – if the data key doesn’t find a match, and this is true, then it will return None rather than False
- class yankee.base.fields.Float(*args, formatter=None, null_value=None, **kwargs)[source]#
Float Field
Always outputs a float value
- class yankee.base.fields.Integer(*args, formatter=None, null_value=None, **kwargs)[source]#
Float Field
Always outputs an integer value. If the value is a float, the result will be the result of calling int on the value.
- class yankee.base.fields.Exists(*args, default=None, **kwargs)[source]#
Exists Field
Outputs true if the data item is present, else false
- class yankee.base.fields.Const(const, output_type=None, *args, **kwargs)[source]#
Constant Field
Always outputs the provided constant value
- Parameters:
const (any) – The constant value to return
- class yankee.base.fields.Dictionary(data_key, key: Field, value: Field, **kwargs)[source]#
- class yankee.base.fields.DelimitedString(item_schema, data_key=None, delimeter=',', **kwargs)[source]#
- class yankee.base.fields.Combine(*args, flatten=False, prefix=False, **kwargs)[source]#
Can have fields like a schema that are then passed as an object to a combine function that transforms it to a single string value
- class yankee.base.fields.Alternative(*args, flatten=False, prefix=False, **kwargs)[source]#
There may be a piece of data that has different names in different contexts. This has fields like a schema, then passes as a value the first non-empty or non-null result
- yankee.base.fields.Alt#
alias of
Alternative
- yankee.base.fields.Dict#
alias of
Dictionary