Package advene :: Package util :: Module autoproperty
[hide private]
[frames] | no frames]

Module autoproperty

source code

Functions [hide private]
 
autoproperty(*args)
Decorate a class method to create or update a property of the class.
source code
 
_infer_name_and_role(method) source code
 
_autoproperty(method, name, role) source code
Function Details [hide private]

autoproperty(*args)

source code 

Decorate a class method to create or update a property of the class.

Usage #1::

   @autoproperty
   def _get_foobar(self):
       # some code

   @autoproperty
   def set_foobar(self, val, option=0)
       # some code

Usage #2::

   @autoproperty("foo", "get")
   def bar(self):
       # some code

   @autoproperty
   def baz(self, val):
       # some code

In the first usage, the name of the property and the role of the method (get, set or del) are inferred from the name of the method. The following name patterns are recognized: role_name, _role_name, roleName, _roleName, where role can be any combination of case. In the two latter cases, the first letter of the name will automatically be downcased.

The docstring of the property is set to the docstring of the first method used to define the property.