Add -p switch

This commit is contained in:
Matteo Cypriani 2018-04-21 23:34:46 +02:00
parent d40548f287
commit 2e0e8ba994
2 changed files with 19 additions and 7 deletions

19
gcp
View File

@ -72,6 +72,7 @@ const_DBUS_INTERFACE = "org.goffi.gcp"
const_DBUS_PATH = "/org/goffi/gcp"
const_BUFF_SIZE = 4096
const_PRESERVE = set(['mode','ownership','timestamps'])
const_PRESERVE_p = 'mode,ownership,timestamps'
const_FS_FIX = set(['auto','force','no'])
const_FILES_DIR = "~/.gcp"
const_JOURNAL_PATH = const_FILES_DIR + "/journal"
@ -559,6 +560,10 @@ class GCP():
action="store_true", default=False,
help=_("force overwriting of existing files")
)
parser.add_argument("-p",
action="store_true", default=False,
help=_("same as --preserve=%s" % const_PRESERVE_p)
)
parser.add_argument("--preserve",
action="store", default='',
help=_("preserve the specified attributes")
@ -641,18 +646,22 @@ class GCP():
if options.no_fs_fix:
options.fs_fix = 'no'
if len(options.preserve):
if options.p:
if not options.preserve:
options.preserve = const_PRESERVE_p
else:
options.preserve += ',' + const_PRESERVE_p
if options.preserve:
preserve = set(options.preserve.split(','))
if not preserve.issubset(const_PRESERVE):
error (_("Invalid --preserve value\nvalid values are:"))
for value in const_PRESERVE:
error('- %s' % value)
exit(1)
else:
options.preserve = preserve
options.preserve = preserve
else:
options.preserve=set()
options.preserve = set()
self.__sourcesSaving(options, args)

7
gcp.1
View File

@ -69,10 +69,13 @@ never follow symbolic links in sources
.B \-f, \-\-force
Overwrite existing files.
.TP
.B \-p
Same as \-\-preserve=mode,ownership,timestamps
.TP
.B \-\-preserve=PRESERVE
Keep specified attributes. Attributes can be mode, ownership and timestamps.
When several attributes are passed, they need to be separated by commas. Note
that timestamps preservation has some limits, see section LIMITS.
that timestamps preservation has some limits, see section LIMITATIONS.
.TP
.B \-\-no\-fs\-fix
Don't fix file system naming incompatibilities.
@ -110,7 +113,7 @@ The exit status can be:
\fB1\fP if at least one file has not been copied, or if something went wrong.
.IP \[bu]
\fB2\fP if all files have been copied but with some issues
.SH LIMITS
.SH LIMITATIONS
Timestamps preservation with \-\-preserve option is limited by the os python
module on POSIX systems. Currently, python only returns timestamps in float
format, which is a smaller precision than what POSIX provides. Progress on this