pyfilesystem
pyfilesystem copied to clipboard
fscp, fs.util.copyfile no-overwrite options
The attached patch introduces a few new features, summarised below:
* fs.commands.Command classes can declare a check_args(parser, options) method
to perform additional assertions on the options passed by the user (such as
mutual exclusivity) and call parser.error to provide feedback where necessary
* fs.util.copyfile now takes an addition "update" argument which overrides the
behaviour of "overwrite" when True. If "update" is True then files are only
copied when the mtime of the source is newer than that of the destination,
raising a fs.errors.DestinationNotOlderError exception otherwise.
* fscp now supports two new, mutually-exclusive options: -n/--no-clobber: do
not overwrite an existing file; and -u/--update: copy only when the SOURCE file
is newer than the destination file or when the destination file is missing.
The argument names have been copied from GNU cp: http://linux.die.net/man/1/cp
Original issue reported on code.google.com by [email protected] on 6 May 2014 at 6:27
Attachments:
s/fs.commands.Command/fs.commands.runners.Command/
Original comment by [email protected] on 6 May 2014 at 6:29
Note: if the mtime of the source or destination path cannot be determined in
copyfile(update=True) then the file is copied.
Original comment by [email protected] on 6 May 2014 at 6:29
This will also require the change in
https://github.com/icio/pyfilesystem/commit/5fea57a5ae78d507ab17992206d7fc2fbb3a
f54d if fscp is going to work with the [-t|--threads] option.
Original comment by [email protected] on 12 May 2014 at 4:29