bgdev.utils.decorator

Useful decorators to use for methods.

created

11/12/2018

author

Benoit GIELLY <benoit.gielly@gmail.com>

REPEAT(func, *, repeat=True, undo=False)

Decorate a method to make it repeatable and/or undoable.

Parameters
  • func (function) – The method to decorate.

  • repeat (bool) – Makes the method repeatable.

  • undo (bool) – Makes the method undoable.

Example

You can use the custom wrappers in this module to decorate your method as you’d like:

import rigging.ui.decorator

@bgdev.ui.decorator.UNDO
def undoable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.REPEAT
def repeatable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.UNDO_REPEAT
def undoable_repeatable_method(*args, **kwargs):
    return args, kwargs
Returns

The decorated method.

Return type

function

UNDO(func, *, repeat=False, undo=True)

Decorate a method to make it repeatable and/or undoable.

Parameters
  • func (function) – The method to decorate.

  • repeat (bool) – Makes the method repeatable.

  • undo (bool) – Makes the method undoable.

Example

You can use the custom wrappers in this module to decorate your method as you’d like:

import rigging.ui.decorator

@bgdev.ui.decorator.UNDO
def undoable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.REPEAT
def repeatable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.UNDO_REPEAT
def undoable_repeatable_method(*args, **kwargs):
    return args, kwargs
Returns

The decorated method.

Return type

function

UNDO_REPEAT(func, *, repeat=True, undo=True)

Decorate a method to make it repeatable and/or undoable.

Parameters
  • func (function) – The method to decorate.

  • repeat (bool) – Makes the method repeatable.

  • undo (bool) – Makes the method undoable.

Example

You can use the custom wrappers in this module to decorate your method as you’d like:

import rigging.ui.decorator

@bgdev.ui.decorator.UNDO
def undoable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.REPEAT
def repeatable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.UNDO_REPEAT
def undoable_repeatable_method(*args, **kwargs):
    return args, kwargs
Returns

The decorated method.

Return type

function

method_decorator(func, repeat=False, undo=False)[source]

Decorate a method to make it repeatable and/or undoable.

Parameters
  • func (function) – The method to decorate.

  • repeat (bool) – Makes the method repeatable.

  • undo (bool) – Makes the method undoable.

Example

You can use the custom wrappers in this module to decorate your method as you’d like:

import rigging.ui.decorator

@bgdev.ui.decorator.UNDO
def undoable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.REPEAT
def repeatable_only_method(*args, **kwargs):
    return args, kwargs

@bgdev.ui.decorator.UNDO_REPEAT
def undoable_repeatable_method(*args, **kwargs):
    return args, kwargs
Returns

The decorated method.

Return type

function

selected(func)[source]

Decorate a func to use selection if no args passed.