1
#------------------------------------------------------------------------------
2
# Copyright (c) 2005, Enthought, Inc.
5
# This software is provided without warranty under the terms of the BSD
6
# license included in enthought/LICENSE.txt and may be redistributed only
7
# under the conditions described in the aforementioned license. The license
8
# is also available online at http://www.enthought.com/licenses/BSD.txt
9
# Thanks for using Enthought open source!
11
# Author: Enthought, Inc.
12
# Description: <Enthought naming package component>
13
#------------------------------------------------------------------------------
14
""" The node manager for a naming tree. """
17
# Enthought library imports.
18
from enthought.pyface.tree.api import NodeManager
21
class NamingNodeManager(NodeManager):
22
""" The node manager for a naming tree. """
24
###########################################################################
25
# 'NodeManager' interface.
26
###########################################################################
28
def get_key(self, node):
29
""" Generates a unique key for a node. """
31
# fixme: This scheme does NOT allow the same object to be in the tree
32
# in more than one place.
33
return self._get_hash_value(node.obj)
35
###########################################################################
37
###########################################################################
39
def _get_hash_value(self, obj):
40
""" Returns a hash value for an object. """
42
# We do it like this 'cos, for example, using id() on a string
43
# doesn't give us what we want, but things like lists aren't
44
# hashable, so we can't always use hash()).
46
hash_value = hash(obj)
53
##### EOF #####################################################################