~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-25 22:19:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1963.
  • Revision ID: john@arbash-meinel.com-20060825221948-b14fa1054682bab2
David Allouche: Make transports return escaped paths

Show diffs side-by-side

added added

removed removed

Lines of Context:
465
465
 
466
466
    def list_dir(self, relpath):
467
467
        """See Transport.list_dir."""
 
468
        mutter("FTP nlst: %s", self._abspath(relpath))
 
469
        f = self._get_FTP()
 
470
        basepath = self._abspath(relpath)
468
471
        try:
469
 
            mutter("FTP nlst: %s", self._abspath(relpath))
470
 
            f = self._get_FTP()
471
 
            basepath = self._abspath(relpath)
472
472
            paths = f.nlst(basepath)
473
 
            # If FTP.nlst returns paths prefixed by relpath, strip 'em
474
 
            if paths and paths[0].startswith(basepath):
475
 
                paths = [path[len(basepath)+1:] for path in paths]
476
 
            # Remove . and .. if present, and return
477
 
            return [path for path in paths if path not in (".", "..")]
478
473
        except ftplib.error_perm, e:
479
474
            self._translate_perm_error(e, relpath, extra='error with list_dir')
 
475
        # If FTP.nlst returns paths prefixed by relpath, strip 'em
 
476
        if paths and paths[0].startswith(basepath):
 
477
            entries = [path[len(basepath)+1:] for path in paths]
 
478
        else:
 
479
            entries = paths
 
480
        # Remove . and .. if present
 
481
        entries = [entry for entry in entries if entry not in (".", "..")]
 
482
        return [urllib.quote(entry) for entry in entries]
480
483
 
481
484
    def iter_files_recursive(self):
482
485
        """See Transport.iter_files_recursive.
485
488
        mutter("FTP iter_files_recursive")
486
489
        queue = list(self.list_dir("."))
487
490
        while queue:
488
 
            relpath = urllib.quote(queue.pop(0))
 
491
            relpath = queue.pop(0)
489
492
            st = self.stat(relpath)
490
493
            if stat.S_ISDIR(st.st_mode):
491
494
                for i, basename in enumerate(self.list_dir(relpath)):