~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/registry.py

  • Committer: Aaron Bentley
  • Date: 2008-03-07 11:46:20 UTC
  • mto: (3251.4.4 lp-service)
  • mto: This revision was merged to the branch mainline in revision 3258.
  • Revision ID: aaron@aaronbentley.com-20080307114620-k8bznm3qigu2bzlh
Add testing of Registry.get_prefix

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
        return self._dict[self._get_key_or_default(key)].get_obj()
169
169
 
170
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
        """
171
177
        for key, value in self.iteritems():
172
178
            if fullname.startswith(key):
173
179
                return value, fullname[len(key):]