Handle --preserve=all

This commit is contained in:
Matteo Cypriani 2018-04-22 07:39:31 +02:00
parent 2e0e8ba994
commit b83d37a5e9
3 changed files with 32 additions and 26 deletions

16
fr.po
View File

@ -197,8 +197,11 @@ msgid "force overwriting of existing files"
msgstr "force le remplacement des fichiers déjà existants" msgstr "force le remplacement des fichiers déjà existants"
#: gcp:545 #: gcp:545
msgid "preserve the specified attributes" #, python-format
msgstr "garde les attributs spécifiés" msgid "preserve the specified attributes; accepted values:\
'all', or one or more amongst %s"
msgstr "garde les attributs spécifiés; valeurs acceptées : 'all' ou\
un ou plusieurs éléments parmi %s"
#: gcp:551 #: gcp:551
msgid "don't fix filesystem name incompatibily" msgid "don't fix filesystem name incompatibily"
@ -245,12 +248,9 @@ msgid "Progress bar is not available, deactivating"
msgstr "La barre de progression n'est pas disponible, désactivation" msgstr "La barre de progression n'est pas disponible, désactivation"
#: gcp:595 #: gcp:595
msgid "" #, python-format
"Invalid --preserve value\n" msgid "Invalid --preserve value '%s'"
"valid values are:" msgstr "Valeur de --preserve invalide « %s »"
msgstr ""
"La valeur de «--preserve» est invalide\n"
"Les valeurs valides sont:"
#: gcp:616 #: gcp:616
#, python-format #, python-format

33
gcp
View File

@ -566,7 +566,8 @@ class GCP():
) )
parser.add_argument("--preserve", parser.add_argument("--preserve",
action="store", default='', action="store", default='',
help=_("preserve the specified attributes") help=_("preserve the specified attributes; accepted values:\
'all', or one or more amongst %s") % str(const_PRESERVE)
) )
parser.add_argument("-L", "--dereference", parser.add_argument("-L", "--dereference",
action="store_true", default=False, action="store_true", default=False,
@ -646,22 +647,26 @@ class GCP():
if options.no_fs_fix: if options.no_fs_fix:
options.fs_fix = 'no' options.fs_fix = 'no'
preserve = set()
if options.p: if options.p:
if not options.preserve: preserve.update(const_PRESERVE_p.split(','))
options.preserve = const_PRESERVE_p
else:
options.preserve += ',' + const_PRESERVE_p
if options.preserve: if options.preserve:
preserve = set(options.preserve.split(',')) preserve.update(options.preserve.split(','))
if not preserve.issubset(const_PRESERVE): preserve_all = False
error (_("Invalid --preserve value\nvalid values are:")) for value in preserve:
for value in const_PRESERVE: if value == 'all':
error('- %s' % value) preserve_all = True
exit(1) continue
options.preserve = preserve if value not in const_PRESERVE:
else: error (_("Invalid --preserve value '%s'") % value)
options.preserve = set() exit(1)
if preserve_all:
preserve.remove('all')
preserve.update(const_PRESERVE)
options.preserve = preserve
self.__sourcesSaving(options, args) self.__sourcesSaving(options, args)

9
gcp.po
View File

@ -120,7 +120,9 @@ msgid "force overwriting of existing files"
msgstr "" msgstr ""
#: gcp:321 #: gcp:321
msgid "preserve the specified attributes" #, python-format
msgid "preserve the specified attributes; accepted values:\
'all', or one or more amongst %s"
msgstr "" msgstr ""
#: gcp:324 #: gcp:324
@ -140,9 +142,8 @@ msgid "Progress bar is not available, deactivating"
msgstr "" msgstr ""
#: gcp:345 #: gcp:345
msgid "" #, python-format
"Invalid --preserve value\n" msgid "Invalid --preserve value '%s'"
"valid values are:"
msgstr "" msgstr ""
#: gcp:354 #: gcp:354