Ignore:
Timestamp:
Dec 23, 2015, 5:10:41 PM (4 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Add `rest` argument to `FTPHost.open`

Allow a `rest` argument in `FTPHost.open`. Pass this on to
`FTPFile._open` and from there to `self._session.transfercmd`.

So far there's no error handling.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/host.py

    r1617 r1618  
    175175
    176176    def open(self, path, mode="r", buffering=None, encoding=None, errors=None,
    177              newline=None):
     177             newline=None, rest=None):
    178178        """
    179179        Return an open file(-like) object which is associated with
    180180        this `FTPHost` object.
     181
     182        The arguments `path`, `mode`, `buffering`, `encoding`, `errors`
     183        and `newlines` have the same meaning as for `io.open`. If `rest`
     184        is given as an integer,
     185
     186        - reading will start at the byte (zero-based) `rest`
     187        - writing will overwrite the remote file from byte `rest`
    181188
    182189        This method tries to reuse a child but will generate a new one
     
    209216                    format(effective_dir))
    210217        host._file._open(effective_file, mode=mode, buffering=buffering,
    211                          encoding=encoding, errors=errors, newline=newline)
     218                         encoding=encoding, errors=errors, newline=newline,
     219                         rest=rest)
    212220        if "w" in mode:
    213221            # Invalidate cache entry because size and timestamps will change.
Note: See TracChangeset for help on using the changeset viewer.