File: trait_dict_context_adapter.py

package info (click to toggle)
python-apptools 4.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,652 kB
  • sloc: python: 16,657; makefile: 77
file content (38 lines) | stat: -rw-r--r-- 1,227 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" Context adapter for trait dictionaries. """


# Enthought library imports.
from traits.api import Dict, Property, Str

# Local imports.
from dict_context_adapter import DictContextAdapter


class TraitDictContextAdapter(DictContextAdapter):
    """ Context adapter for trait dictionaries. """

    #### 'Context' interface ##################################################

    # The name of the context within its own namespace.
    namespace_name = Property(Str)

    #### 'ContextAdapter' interface ###########################################

    # The object that we are adapting.
    adaptee = Dict

    #### 'TraitDictContextAdapter' interface ##################################

    # The name of the object's trait that provides the dictionary.
    trait_name = Str

    ###########################################################################
    # 'Context' interface.
    ###########################################################################

    def _get_namespace_name(self):
        """ Returns the name of the context within its own namespace. """

        return self.context.namespace_name + '/' + self.trait_name

#### EOF ######################################################################