| 1 |
from Base.Metadata import export, constmethod |
| 2 |
from Base.Persistence import Persistence |
| 3 |
from typing import Any, Final, Union, List, Optional |
| 4 |
|
| 5 |
|
| 6 |
@export( |
| 7 |
DisableNotify=True, |
| 8 |
) |
| 9 |
class PropertyContainer(Persistence): |
| 10 |
""" |
| 11 |
App.PropertyContainer class. |
| 12 |
""" |
| 13 |
|
| 14 |
PropertiesList: Final[list] = [] |
| 15 |
"""A list of all property names.""" |
| 16 |
|
| 17 |
def getPropertyByName(self, name: str, checkOwner: int = 0) -> Any: |
| 18 |
""" |
| 19 |
getPropertyByName(name, checkOwner=0) -> object or Tuple |
| 20 |
|
| 21 |
Returns the value of a named property. Note that the returned property may not |
| 22 |
always belong to this container (e.g. from a linked object). |
| 23 |
|
| 24 |
name : str |
| 25 |
Name of the property. |
| 26 |
checkOwner : int |
| 27 |
0: just return the property. |
| 28 |
1: raise exception if not found or the property does not belong to this container. |
| 29 |
2: return a tuple (owner, propertyValue). |
| 30 |
""" |
| 31 |
... |
| 32 |
|
| 33 |
def getPropertyTouchList(self, name: str) -> tuple: |
| 34 |
""" |
| 35 |
getPropertyTouchList(name) -> tuple |
| 36 |
|
| 37 |
Returns a list of index of touched values for list type properties. |
| 38 |
|
| 39 |
name : str |
| 40 |
Property name. |
| 41 |
""" |
| 42 |
... |
| 43 |
|
| 44 |
def getTypeOfProperty(self, name: str) -> list: |
| 45 |
""" |
| 46 |
getTypeOfProperty(name) -> list |
| 47 |
|
| 48 |
Returns the type of a named property. This can be a list conformed by elements in |
| 49 |
(Hidden, NoRecompute, NoPersist, Output, ReadOnly, Transient). |
| 50 |
|
| 51 |
name : str |
| 52 |
Property name. |
| 53 |
""" |
| 54 |
... |
| 55 |
|
| 56 |
def getTypeIdOfProperty(self, name: str) -> str: |
| 57 |
""" |
| 58 |
getTypeIdOfProperty(name) -> str |
| 59 |
|
| 60 |
Returns the C++ class name of a named property. |
| 61 |
|
| 62 |
name : str |
| 63 |
Property name. |
| 64 |
""" |
| 65 |
... |
| 66 |
|
| 67 |
def setEditorMode(self, name: str, type: Union[int, List[str]]) -> None: |
| 68 |
""" |
| 69 |
setEditorMode(name, type) -> None |
| 70 |
|
| 71 |
Set the behaviour of the property in the property editor. |
| 72 |
|
| 73 |
name : str |
| 74 |
Property name. |
| 75 |
type : int, sequence of str |
| 76 |
Property type. |
| 77 |
0: default behaviour. 1: item is ready-only. 2: item is hidden. 3: item is hidden and read-only. |
| 78 |
If sequence, the available items are 'ReadOnly' and 'Hidden'. |
| 79 |
""" |
| 80 |
... |
| 81 |
|
| 82 |
def getEditorMode(self, name: str) -> list: |
| 83 |
""" |
| 84 |
getEditorMode(name) -> list |
| 85 |
|
| 86 |
Get the behaviour of the property in the property editor. |
| 87 |
It returns a list of strings with the current mode. If the list is empty there are no |
| 88 |
special restrictions. |
| 89 |
If the list contains 'ReadOnly' then the item appears in the property editor but is |
| 90 |
disabled. |
| 91 |
If the list contains 'Hidden' then the item even doesn't appear in the property editor. |
| 92 |
|
| 93 |
name : str |
| 94 |
Property name. |
| 95 |
""" |
| 96 |
... |
| 97 |
|
| 98 |
def getGroupOfProperty(self, name: str) -> str: |
| 99 |
""" |
| 100 |
getGroupOfProperty(name) -> str |
| 101 |
|
| 102 |
Returns the name of the group which the property belongs to in this class. |
| 103 |
The properties are sorted in different named groups for convenience. |
| 104 |
|
| 105 |
name : str |
| 106 |
Property name. |
| 107 |
""" |
| 108 |
... |
| 109 |
|
| 110 |
def setGroupOfProperty(self, name: str, group: str) -> None: |
| 111 |
""" |
| 112 |
setGroupOfProperty(name, group) -> None |
| 113 |
|
| 114 |
Set the name of the group of a dynamic property. |
| 115 |
|
| 116 |
name : str |
| 117 |
Property name. |
| 118 |
group : str |
| 119 |
Group name. |
| 120 |
""" |
| 121 |
... |
| 122 |
|
| 123 |
def setPropertyStatus( |
| 124 |
self, name: str, val: Union[int, str, List[Union[str, int]]] |
| 125 |
) -> None: |
| 126 |
""" |
| 127 |
setPropertyStatus(name, val) -> None |
| 128 |
|
| 129 |
Set property status. |
| 130 |
|
| 131 |
name : str |
| 132 |
Property name. |
| 133 |
val : int, str, sequence of str or int |
| 134 |
Call getPropertyStatus() to get a list of supported text value. |
| 135 |
If the text start with '-' or the integer value is negative, then the status is cleared. |
| 136 |
""" |
| 137 |
... |
| 138 |
|
| 139 |
def getPropertyStatus(self, name: str = "") -> list: |
| 140 |
""" |
| 141 |
getPropertyStatus(name='') -> list |
| 142 |
|
| 143 |
Get property status. |
| 144 |
|
| 145 |
name : str |
| 146 |
Property name. If empty, returns a list of supported text names of the status. |
| 147 |
""" |
| 148 |
... |
| 149 |
|
| 150 |
def getDocumentationOfProperty(self, name: str) -> str: |
| 151 |
""" |
| 152 |
getDocumentationOfProperty(name) -> str |
| 153 |
|
| 154 |
Returns the documentation string of the property of this class. |
| 155 |
|
| 156 |
name : str |
| 157 |
Property name. |
| 158 |
""" |
| 159 |
... |
| 160 |
|
| 161 |
def setDocumentationOfProperty(self, name: str, docstring: str) -> None: |
| 162 |
""" |
| 163 |
setDocumentationOfProperty(name, docstring) -> None |
| 164 |
|
| 165 |
Set the documentation string of a dynamic property of this class. |
| 166 |
|
| 167 |
name : str |
| 168 |
Property name. |
| 169 |
docstring : str |
| 170 |
Documentation string. |
| 171 |
""" |
| 172 |
... |
| 173 |
|
| 174 |
def getEnumerationsOfProperty(self, name: str) -> Optional[list]: |
| 175 |
""" |
| 176 |
getEnumerationsOfProperty(name) -> list or None |
| 177 |
|
| 178 |
Return all enumeration strings of the property of this class or None if not a |
| 179 |
PropertyEnumeration. |
| 180 |
|
| 181 |
name : str |
| 182 |
Property name. |
| 183 |
""" |
| 184 |
... |
| 185 |
|
| 186 |
@constmethod |
| 187 |
def dumpPropertyContent(self, Property: str, *, Compression: int = 3) -> bytearray: |
| 188 |
""" |
| 189 |
dumpPropertyContent(Property, Compression=3) -> bytearray |
| 190 |
|
| 191 |
Dumps the content of the property, both the XML representation and the additional |
| 192 |
data files required, into a byte representation. |
| 193 |
|
| 194 |
Property : str |
| 195 |
Property Name. |
| 196 |
Compression : int |
| 197 |
Set the data compression level in the range [0, 9]. Set to 0 for no compression. |
| 198 |
""" |
| 199 |
... |
| 200 |
|
| 201 |
def restorePropertyContent(self, name: str, obj: object) -> None: |
| 202 |
""" |
| 203 |
restorePropertyContent(name, obj) -> None |
| 204 |
|
| 205 |
Restore the content of the object from a byte representation as stored by `dumpPropertyContent`. |
| 206 |
It could be restored from any Python object implementing the buffer protocol. |
| 207 |
|
| 208 |
name : str |
| 209 |
Property name. |
| 210 |
obj : buffer |
| 211 |
Object with buffer protocol support. |
| 212 |
""" |
| 213 |
... |
| 214 |
|
| 215 |
@constmethod |
| 216 |
def renameProperty(self, oldName: str, newName: str) -> None: |
| 217 |
""" |
| 218 |
renameProperty(oldName, newName) -> None |
| 219 |
|
| 220 |
Rename a property. |
| 221 |
|
| 222 |
oldName : str |
| 223 |
Old property name. |
| 224 |
newName : str |
| 225 |
New property name. |
| 226 |
""" |
| 227 |
... |