piranna / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

fscp, fs.util.copyfile no-overwrite options #177

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 p...@duedil.com on 6 May 2014 at 6:27

Attachments:

GoogleCodeExporter commented 9 years ago
s/fs.commands.Command/fs.commands.runners.Command/

Original comment by p...@duedil.com on 6 May 2014 at 6:29

GoogleCodeExporter commented 9 years ago
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 p...@duedil.com on 6 May 2014 at 6:29

GoogleCodeExporter commented 9 years ago
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 p...@duedil.com on 12 May 2014 at 4:29