~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/registry.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-03-10 15:38:03 UTC
  • mfrom: (3251.3.6 bzr.ab.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080310153803-uy09bhh0ls8tavcx
Add support for directory services (abentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
        """
168
168
        return self._dict[self._get_key_or_default(key)].get_obj()
169
169
 
 
170
    def get_prefix(self, fullname):
 
171
        """Return an object whose key is a prefix of the supplied value.
 
172
 
 
173
        :fullname: The name to find a prefix for
 
174
        :return: a tuple of (object, remainder), where the remainder is the
 
175
            portion of the name that did not match the key.
 
176
        """
 
177
        for key, value in self.iteritems():
 
178
            if fullname.startswith(key):
 
179
                return value, fullname[len(key):]
 
180
 
170
181
    def _get_key_or_default(self, key=None):
171
182
        """Return either 'key' or the default key if key is None"""
172
183
        if key is not None: