Model Extensions
ExtendedBaseModel
Bases: BaseModel
Source code in catena/models/extensions.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
__eq__(other)
Dunder method for allowing comparison of Options instances. If two instances are the same will return True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
other instance of Options to compare with |
required |
Source code in catena/models/extensions.py
18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
__setitem__(name, value)
Dunder method for allowing setting attributes dictionary style
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of attribute to set |
required |
value |
Any
|
value to set attribute to |
required |
Source code in catena/models/extensions.py
7 8 9 10 11 12 13 14 15 16 |
|
get(keyname, value=None)
Analogue to dict.get(keyname, value)
for Pydantic models
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyname |
str
|
name of attribute for which to return the corresponding value |
required |
value |
Any
|
value to return if |
None
|
Source code in catena/models/extensions.py
69 70 71 72 73 74 75 76 77 78 79 |
|
pop(keyname, value=None)
Analogue to dict.pop(keyname, value)
for Pydantic models
Will remove the attribute from the model and return it's value if it has been set,
otherwise it will return value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyname |
str
|
name of attribute to remove and return it's value |
required |
value |
Any
|
value to return if |
None
|
Source code in catena/models/extensions.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
setdefault(keyname, value)
Analogue to dict.setdefault(keyname, value)
for Pydantic models
Will set the value of the corresponding attribute, keyname
if it has not been set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyname |
str
|
name of attribute to set default value for |
required |
value |
Any
|
value to set if attribute has not been set to a non-default value already |
required |
Source code in catena/models/extensions.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|