| 1 |
from abc import abstractmethod |
| 2 |
from collections.abc import Mapping |
| 3 |
from copy import copy, deepcopy |
| 4 |
from typing import Any |
| 5 |
|
| 6 |
|
| 7 |
class BaseOperator(Mapping): |
| 8 |
""" |
| 9 |
Base operator. |
| 10 |
""" |
| 11 |
|
| 12 |
@property |
| 13 |
@abstractmethod |
| 14 |
def query(self) -> Mapping[str, Any]: ... |
| 15 |
|
| 16 |
def __getitem__(self, item: str): |
| 17 |
return self.query[item] |
| 18 |
|
| 19 |
def __iter__(self): |
| 20 |
return iter(self.query) |
| 21 |
|
| 22 |
def __len__(self): |
| 23 |
return len(self.query) |
| 24 |
|
| 25 |
def __repr__(self): |
| 26 |
return repr(self.query) |
| 27 |
|
| 28 |
def __str__(self): |
| 29 |
return str(self.query) |
| 30 |
|
| 31 |
def __copy__(self): |
| 32 |
return copy(self.query) |
| 33 |
|
| 34 |
def __deepcopy__(self, memodict: dict[str, Any] = {}): |
| 35 |
return deepcopy(self.query) |
| 36 |
|
| 37 |
def copy(self): |
| 38 |
return copy(self) |