ravestate.property

Property

Property(self, *, name='', allow_read=True, allow_write=True, allow_push=True, allow_pop=True, default_value=None, always_signal_changed=False, is_flag_property=False, wipe_on_changed=True, boring=False)

Base class for context properties. Controls read/write/push/pop/delete permissions, property name basic impls. for the property value, parent/child mechanism.

Example (Creating a module containing a property named my_property):

with Module(name="my_module"):
    my_property = Property(name="my_property")

set_parent_path

Property.set_parent_path(self, path)

Set the ancestors (including modulename) for a property

  • path: ancestry in the form of modulename:parent_prop_name (or simply modulename)

gather_children

Property.gather_children(self) -> List[ForwardRef('Property')]

Collect this property, and all of it's children.

read

Property.read(self)

Read the current property value

write

Property.write(self, value)

Write a new value to the property

  • value: The new value.

Returns: True if the value has changed and :changed should be signaled, false otherwise.

push

Property.push(self, child: 'Property')

Add a child to the property

  • child: The child object

Returns: True if the child was added successfully, false otherwise.

pop

Property.pop(self, child_name: str)

Remove a child from the property by it's name.

  • child_name: Name of the child to be removed.

Returns: True if the pop was successful, False otherwise

changed

Property.changed(self) -> ravestate.constraint.Signal

Signal that is emitted by PropertyWrapper when write() returns True.

pushed

Property.pushed(self) -> ravestate.constraint.Signal

Signal that is emitted by PropertyWrapper when push() returns True.

popped

Property.popped(self) -> ravestate.constraint.Signal

Signal that is emitted by PropertyWrapper when pop() returns True.

true

Property.true(self) -> ravestate.constraint.Signal

Signal that is emitted by PropertyWrapper when it is a flag-property and self.value is set to True.

false

Property.false(self) -> ravestate.constraint.Signal

Signal that is emitted by PropertyWrapper when it is a flag-property and self.value is set to False.

signals

Property.signals(self) -> Generator[ravestate.constraint.Signal, NoneType, NoneType]

Yields all signals that may be emitted because of this property, given it's write/push/pop permissions.