~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2005-10-04 06:39:39 UTC
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1403.
  • Revision ID: mbp@sourcefrog.net-20051004063939-c9f2e5f9a5fa046c
- add docstring demonstrating use of Inventory.id2path

Show diffs side-by-side

added added

removed removed

Lines of Context:
915
915
 
916
916
 
917
917
    def id2path(self, file_id):
918
 
        """Return as a list the path to file_id."""
919
 
 
 
918
        """Return as a list the path to file_id.
 
919
        
 
920
        >>> i = Inventory()
 
921
        >>> e = i.add(InventoryDirectory('src-id', 'src', ROOT_ID))
 
922
        >>> e = i.add(InventoryFile('foo-id', 'foo.c', parent_id='src-id'))
 
923
        >>> print i.id2path('foo-id').replace(os.sep, '/')
 
924
        src/foo.c
 
925
        """
920
926
        # get all names, skipping root
921
927
        p = [self._byid[fid].name for fid in self.get_idpath(file_id)[1:]]
922
928
        return os.sep.join(p)