--- ../ftputil-2.1/ftputil.py 2006-03-01 19:55:46.000000000 -0500 +++ ftputil.py 2006-07-20 17:25:48.000000000 -0400 @@ -697,6 +697,20 @@ """ return self._stat.stat(path, _exception_for_missing_path) + def statdir(self, path, _exception_for_missing_path=True): + """ + Return a list of "stat" info for each file in the directory `path`. + + If the directory `path` can't be parsed, raise a `ParserError`. If + the directory containing `path` can be parsed but the `path` can't + be found, raise a `PermanentError`. + + (`_exception_for_missing_path` is an implementation aid and + _not_ intended for use by ftputil clients.) + + """ + return self._stat.statdir(path, _exception_for_missing_path=True) + def walk(self, top, topdown=True, onerror=None): """ Iterate over directory tree and return a tuple (dirpath, --- ../ftputil-2.1/ftp_stat.py 2006-02-19 12:01:38.000000000 -0500 +++ ftp_stat.py 2006-07-20 17:26:07.000000000 -0400 @@ -449,6 +449,36 @@ # remember the path we have encountered visited_paths[path] = True + def _real_statdir(self, path, _exception_for_missing_path=True): + """ + Return a list of "stat" info for each file in the directory `path`. + Do not follow symbolic links (i.e. like "lstat") + + If the directory `path` can't be parsed, raise a `ParserError`. If + the directory containing `path` can be parsed but the `path` can't + be found, raise a `PermanentError`. + + (`_exception_for_missing_path` is an implementation aid and + _not_ intended for use by ftputil clients.) + + """ + # get output from FTP's `DIR` command + lines = [] + path = self._path.abspath(path) + lines = self._host_dir(path) + result = [] + for line in lines: + try: + stat_result = self._parser.parse_line(line, + self._host.time_shift()) + result.append(stat_result) + except ftp_error.ParserError: + # ignore things like "total 17", as found in some + # server listings + if not line.lower().startswith("total"): + raise + return result + def __call_with_parser_retry(self, method, *args, **kwargs): """ Call `method` with the `args` and `kwargs` once. If that @@ -483,3 +513,6 @@ return self.__call_with_parser_retry(self._real_stat, path, _exception_for_missing_path) + def statdir(self, path, _exception_for_missing_path=True): + return self.__call_with_parser_retry(self._real_statdir, path, + _exception_for_missing_path)