b3j0f.annotation.oop module

Annotations dedicated to object oriented programming.

class b3j0f.annotation.oop.Transform(name=None, bases=(<class 'b3j0f.annotation.core.Annotation'>, ), dict={}, update=True)[source]

Bases: b3j0f.annotation.core.Annotation

Transform a class into an annotation or something else if parameters are different.

BASES = 'bases'
DEFAULT_BASES = (<class 'b3j0f.annotation.core.Annotation'>,)
DEFAULT_DICT = {}
DICT = 'dict'
NAME = 'name'
UPDATE = 'update'
bases
dict
name
override
propagate
targets
update
class b3j0f.annotation.oop.Mixin(classes=(), *attributes, **named_attributes)[source]

Bases: b3j0f.annotation.core.Annotation

Annotation which enrichs a target with Mixin.

For every defined mixin, a private couple of (name, array of mixed items) is created into the target in order to go back in a no mixin state.

exception MixInError[source]

Bases: exceptions.Exception

Raised for any Mixin error.

static Mixin.get_mixedins_by_name(target)[source]

Get a set of couple (name, field) of target mixedin.

static Mixin.mixin(target, resource, name=None)[source]

Do the correct mixin depending on the type of input resource.

  • Method or Function: mixin_function_or_method.
  • class: mixin_class.
  • other: set_mixin.

And returns the result of the choosen method (one or a list of mixins).

static Mixin.mixin_class(target, cls)[source]

Mix cls content in target.

static Mixin.mixin_function_or_method(target, fm, name=None, bound_method=False)[source]

Mixin a function or a method into the target.

If name is not given, then the fm name is used. If bound method is True (False by default), the mixin result is a bound method to target.

Mixin.on_bind_target(target, ctx, *args, **kwargs)[source]
static Mixin.remove_all_mixins(target, name=None)[source]

Tries to get back target in a no mixin consistent state. If name is given, then all mixin related to input name may be removed.

static Mixin.remove_mixin(target, name, mixedin=None, set=True)[source]

Remove a mixin with name (and reference) from targetand returns the replaced one or None.

The mixedin parameter designates a mixedin value or the last defined mixedin if is None (default). If set is True (default), the removed mixedin replaces the current mixin.

static Mixin.set_mixin(target, resource, name=None, override=True)[source]

Set a resource and returns the mixed one in target content or Mixin.__NEW_CONTENT_KEY__ if resource name didn’t exist in target.

The optional input property name designates the target content item to mix with the resource. The override parameter (True by default) permits to replace an old resource by the new one.

class b3j0f.annotation.oop.Deprecated(*args, **kwargs)[source]

Bases: b3j0f.annotation.interception.PrivateInterceptor

Decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

class b3j0f.annotation.oop.Singleton(*args, **kwargs)[source]

Bases: b3j0f.annotation.core.Annotation

Transforms cls into a singleton.

Reference to cls, or to any instance is the same reference.

class b3j0f.annotation.oop.MethodMixin(function, *args, **kwargs)[source]

Bases: b3j0f.annotation.core.Annotation

Apply a mixin on a method.

Previous topic

b3j0f.annotation.interception module

This Page