pytan3.api_models.
ApiModel
[source]¶Bases: object
Base class for all models in the API.
T_ATTR_DESC
= ' - {api_type} attribute {attr!r} of type {attr_type!r}'¶str
– Template for attr line in api_attrs_desc()
.
T_DESC
= 'Defined attributes:'¶str
– Template for first line in api_attrs_desc()
.
API_STR
= ['id', 'name', 'display_name', 'value', 'type', 'public_flag', 'hidden_flag', 'question', 'query_text', 'question_text', 'expiration', 'saved_question']¶list
of str
– Attrs to display in str or to put first in repr.
__eq__
(value)[source]¶Support for self == value.
Parameters: | value (dict or list or ApiModel or object ) – Value for comparison. |
---|
Notes
Returns: | bool |
---|
__ne__
(value)[source]¶Support for self != value.
Parameters: | value (dict or list or ApiModel or object ) – Value for comparison. |
---|---|
Returns: | bool |
api_attrs_repr
()[source]¶Get attributes for repr formatting.
Notes
Will return attrs without dupes in order of priority to show on
format string from API_STR
, API_STR_ADD
,
and api_attrs()
.
Returns: | list of str |
---|
api_attrs_str
()[source]¶Get attributes for str formatting.
Notes
Will return attrs without dupes in order of priority to show on
format string from API_STR
and API_STR_ADD
.
If no attrs from API_STR
and API_STR_ADD
exist
in api_attrs()
, return all attrs from api_attrs()
.
Returns: | list of str |
---|
api_attrs_desc
()[source]¶Get description of attrs from API_SIMPLE
and API_COMPLEX
.
Notes
Used by exceptions to add defined attributes to error messages.
Returns: | list of str |
---|
api_coerce_int
(value)[source]¶Try to coerce value into int
if possible.
Parameters: | value (object ) – Object to coerce into int. |
---|---|
Returns: | int or object if unchanged. |
api_coerce_float
(value)[source]¶Try to coerce value into float
if possible.
Parameters: | value (object ) – Object to coerce into float. |
---|---|
Returns: | float or object if unchanged. |
api_coerce_list
(value)[source]¶Coerce value into list
if it is not already.
Parameters: | value (object ) – Object to coerce into list. If value is None, will return empty list. |
---|---|
Returns: | list or object if unchanged. |
api_coerce_simple
(value, be_type)[source]¶Try to coerce a value into a simple type.
Parameters: | |
---|---|
Returns: |
api_coerce_complex
(value, be_type)[source]¶Try to coerce a value into a complex type.
Parameters: | |
---|---|
Returns: |
api_coerce_value
(attr, value)[source]¶Perform type checking of value.
Will coerce value into expected type if needed and possible.
Parameters: | |
---|---|
Raises: |
|
Notes
Returns: | object |
---|