b3j0f.utils.proxy module

Module in charge of creating proxies like the design pattern proxy.

A proxy is based on a callable element. It respects its signature but not the implementation.

b3j0f.utils.proxy.get_proxy(elt, bases=None, _dict=None)[source]

Get proxy from an elt.

If elt implements the proxy generator method (named __getproxy__), use it instead of using this module functions.

Parameters:
  • elt (object or function/method) – elt to proxify.
  • bases – base types to enrich in the result cls if not None.
  • _dict – class members to proxify if not None.
b3j0f.utils.proxy.proxify_routine(routine, impl=None)[source]

Proxify a routine with input impl.

Parameters:
  • routine – routine to proxify.
  • impl – new impl to use. If None, use routine.
b3j0f.utils.proxy.proxify_elt(elt, bases=None, _dict=None, public=False)[source]

Proxify input elt.

Parameters:
  • elt – elt to proxify.
  • bases – elt class base classes. If None, use elt type.
  • _dict (dict) – specific elt class content to use.
  • public (bool) – if True (default False), proxify only public members (where name starts with the character ‘_’).
Returns:

proxified element.

Raises:

TypeError if elt does not implement all routines of bases and _dict.

b3j0f.utils.proxy.is_proxy(elt)[source]

Return True if elt is a proxy.

Parameters:elt – elt to check such as a proxy.
Returns:True iif elt is a proxy.
Return type:bool
b3j0f.utils.proxy.proxified_elt(proxy)[source]

Get proxified element.

Parameters:proxy – proxy element from where get proxified element.
Returns:proxified element. None if proxy is not proxified.