pytilities.delegation.profile

class pytilities.delegation.profile.Profile

States what attributes to delegate, and to which target attributes.

_Profile__are_conflict_free(other)
Returns:True if mappings of self don’t conflict with those of other
__and__(other)
__iand__(other)

intersection of this profile and the other

Parameters:
  • other (Profile) – the other profile
Preconditions :

1. The mappings of the two profiles musn’t conflict. Two profiles conflict when they have at least one mapping with the same source name, but a different target name.

__init__()
__ior__(other)

union of this profile and the other

Parameters:
  • other (Profile) – the other profile
Preconditions :

1. The mappings of the two profiles musn’t conflict. Two profiles conflict when they have at least one mapping with the same source name, but a different target name.

__isub__(other)

difference of this profile and the other

Parameters:
  • other (Profile) – the other profile
__ixor__(other)

symetric difference of this profile and the other

Parameters:
  • other (Profile) – the other profile
__or__(other)

See __ior__

__str__()
__sub__(other)
__xor__(other)
add_mappings(modifiers, *names, **mapped_names)

Map source to target attribute names, for delegation.

Parameters:
  • modifiers (string) –

    the types of delegation access to the target. Valid modifiers are combinations of:

    • ‘r’: read
    • ‘w’: write
    • ‘d’: delete
  • names ((string...)) – source names of the attribute names to delegate. The target attribute name is the same as source_name. This is the same as adding a {source_name : source_name} mapping, using the mapped_names argument.
  • mapped_names ({source_name of string : target_name of string}) –

    names of source and target attributes to map and delegate.

    target_name will be mangled if they have a __ prefix. Mangling will occur every time it is delegated to, so you can change the target object any time.

copy()
get_deletable(attribute)

Get the mapped value of a deletable attribute

Return type:string
get_readable(attribute)

Get the mapped value of a readable attribute

Return type:string
get_writable(attribute)

Get the mapped value of a writable attribute

Return type:string
has_deletable(attribute)

Check for delete-access mapping of attribute

Returns:True if the mapping exists
has_readable(attribute)

Check for read-access mapping of attribute

Returns:True if the mapping exists
has_writable(attribute)

Check for write-access mapping of attribute

Returns:True if the mapping exists
remove_mappings(modifiers, *names)

Remove attribute mappings

Parameters:
  • modifiers (string) –

    the types of delegation access to the target. Valid modifiers are combinations of:

    • ‘r’: read
    • ‘w’: write
    • ‘d’: delete
  • names ((string...)) – source names of the attribute names to remove
__weakref__

list of weak references to the object (if defined)

attributes

Get all attributes, no matter what access they provide

Returns:(attribute_name, ...)
Return type:iter(str, ...)
deletables

Get all deletables attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)
readables

Get all readable attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)
writables

Get all writables attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)

Previous topic

pytilities.delegation.delegationaspect

Next topic

pytilities.delegation.decorators

This Page