Module csw.CurrentState
Classes
class CurrentState (prefix: Prefix,
stateName: str,
paramSet: List[Parameter])-
Expand source code
@dataclass class CurrentState: """ Represents the current state of a python based CSW component. """ prefix: Prefix stateName: str paramSet: List[Parameter] @staticmethod def _fromDict(obj): """ Returns a CurrentState for the given dict. """ prefix = Prefix.from_str(obj['prefix']) stateName = obj['stateName'] paramSet = list(map(lambda p: Parameter._fromDict(p), obj['paramSet'])) return CurrentState(prefix, stateName, paramSet) def _asDict(self): """ Returns: dict a dictionary corresponding to this object """ return { 'prefix': str(self.prefix), 'stateName': self.stateName, 'paramSet': list(map(lambda p: p._asDict(), self.paramSet)) } def __call__(self, key: Key[T]) -> Parameter[T] | None: """ This is similar to Scala's apply() method and gets the parameter for the given key, or else returns None. Args: key (Key[T]): parameter key Returns: Parameter[T] | None the parameter, if found """ for p in self.paramSet: if p.keyName == key.keyName: return p # noinspection PyUnusedLocal def get(self, keyName: str, keyType: KeyType[T]) -> Parameter[T] | None: """ Gets the parameter with the given name, or else returns None. Args: keyName (str): parameter name keyType (KeyType[T]): parameter key type (used only for type hint: See also gets(keyName)) Returns: Parameter[T] | None the parameter, if found """ for p in self.paramSet: if p.keyName == keyName: return p def gets(self, keyName: str) -> Parameter | None: """ Gets the parameter with the given name, or else returns None. Args: keyName (str): parameter name Returns: Parameter | None the parameter, if found """ for p in self.paramSet: if p.keyName == keyName: return p def exists(self, keyName: str): """ Returns true if the parameter with the given name is present Args: keyName (str): parameter name Returns: bool true if the parameter is found """ for p in self.paramSet: if p.keyName == keyName: return True return False
Represents the current state of a python based CSW component.
Instance variables
var paramSet : List[Parameter]
-
The type of the None singleton.
var prefix : Prefix
-
The type of the None singleton.
var stateName : str
-
The type of the None singleton.
Methods
def exists(self, keyName: str)
-
Expand source code
def exists(self, keyName: str): """ Returns true if the parameter with the given name is present Args: keyName (str): parameter name Returns: bool true if the parameter is found """ for p in self.paramSet: if p.keyName == keyName: return True return False
Returns true if the parameter with the given name is present
Args
keyName
:str
- parameter name
Returns: bool true if the parameter is found
def get(self,
keyName: str,
keyType: KeyType[~T]) ‑> Parameter[~T] | None-
Expand source code
def get(self, keyName: str, keyType: KeyType[T]) -> Parameter[T] | None: """ Gets the parameter with the given name, or else returns None. Args: keyName (str): parameter name keyType (KeyType[T]): parameter key type (used only for type hint: See also gets(keyName)) Returns: Parameter[T] | None the parameter, if found """ for p in self.paramSet: if p.keyName == keyName: return p
Gets the parameter with the given name, or else returns None.
Args
keyName
:str
- parameter name
keyType
:KeyType[T]
- parameter key type (used only for type hint: See also gets(keyName))
Returns: Parameter[T] | None the parameter, if found
def gets(self, keyName: str) ‑> Parameter | None
-
Expand source code
def gets(self, keyName: str) -> Parameter | None: """ Gets the parameter with the given name, or else returns None. Args: keyName (str): parameter name Returns: Parameter | None the parameter, if found """ for p in self.paramSet: if p.keyName == keyName: return p
Gets the parameter with the given name, or else returns None.
Args
keyName
:str
- parameter name
Returns: Parameter | None the parameter, if found