Entities¶
Entities (or, simply, objects) are the essential part of gd.py.
Main interaction with data returned from GD servers is achieved through them.
A base class for all entities is AbstractEntity.
-
class
gd.AbstractEntity(*, client: Optional[Client] = None, **options)[source]¶ Class that represents Abstract Entity. This is a base for many gd.py objects.
-
x == y Check if two objects are equal. Compared by hash and type.
-
x != y Check if two objects are not equal.
-
hash(x) Returns
hash(self.hash_str).
-
classmethod
from_model(model: gd.model_backend.Model, *args, **kwargs) → AbstractEntityT[source]¶ Create new entity from given
model,argsandkwargs.
-
classmethod
from_models(*models: gd.model_backend.Model, **kwargs) → AbstractEntityT[source]¶ Create new entity from given
modelsby callingfrom_modelwithkwargs.
-
classmethod
from_dicts(*data: Dict[str, Any], client: Optional[Client] = None, **kwargs) → AbstractEntityT[source]¶ Create new entity from dictionaries in
data, withclientandkwargs.
-
classmethod
from_dict(*data: Dict[str, Any], client: Optional[Client] = None, **kwargs) → AbstractEntityT¶ Create new entity from dictionaries in
data, withclientandkwargs.
-
property
client¶ Client attached to this object. This checks if client is not present, and raises
ClientExceptionin that case.- Type
-
attach_client(client: Optional[Client] = None) → AbstractEntityT[source]¶ Attach
clienttoself.- Parameters
client (Optional[
gd.Client]) – Client to attach. IfNoneor not given, will be detached.- Returns
This abstract entity.
- Return type
-