pytweezer.servers.properties module

class pytweezer.servers.properties.Properties(name, initfromfile=False)[source]

Bases: Thread

changes(includeparent=True)[source]

return keys of all entries that have changed since the last call of this function

Parameters:

includeparent (bool) – if True the parent classes will be included in the list of changes

Returns:

set of changes since last call of this function

Return type:

set()

delete(key)[source]

delete an entry including its subentries

Parameters:

key (str) – entry to be deleted

Returns:

None.

get(key, defaultvalue=None)[source]

returns values from dictionary for details see set(). Values are always deep copies

Parameters:
  • key (str) – key of the dictionary

  • defaultvalue – used to create the entry in case it is not yet existing

Returns:

the entry from the property dictionary

It is a good habit to always give reasonable default values so the property tree can create and maintain itself.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

set(key, value)[source]

set property

Parameters:
  • key (string) or (list of strings) – property to be set adressing is similar to filesystem if the string is starting with ‘/ start from dictionary root else start from entry=name

  • value (anything) – Anything you consider a useful value. Must be json serializable! (no self defined classes unless you know …)

  • _global (bool) – keys will the have to be a list with the first entry being the name of the program whose Parameters should be modified

class pytweezer.servers.properties.PropertyAttribute(propname, defaultval, parent=None)[source]

Bases: object

access properties as Attributes. The class object using this attribute must have an attribute called _props of type Properties. The value property can be used to do basic manipulation of the property e.g. get, set, addition att = PropertyAttribute(propname, defaultval, parent=self) exmaples: getting: x = att.value. gets the property value and sets x with it addition: att.value += 1. this changes both the property and self.att indexing: element_2 = att.value[2]. this gets the second element of the property att.value.append() doesn’t work! do: lst = att.value lst.append() att.value = lst

x = att gets the property value and sets x with it att = x sets the property value BUT OVERWRITES att (i.e. if x is an int, att will also become an int), so it only works once. Therefore, using att.value is preferred.

property value