enable placeholder usage in --glob-archives, fixes #4495

they are supported for --prefix already, so it totally makes sense to
also support them for the more powerful/generic --glob-archives.
This commit is contained in:
Thomas Waldmann 2019-05-09 20:28:41 +02:00
parent c78c3ff8a4
commit fb05da42cf
2 changed files with 6 additions and 4 deletions

View File

@ -50,7 +50,7 @@ try:
from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
from .helpers import Error, NoManifestError, set_ec from .helpers import Error, NoManifestError, set_ec
from .helpers import positive_int_validator, location_validator, archivename_validator, ChunkerParams, Location from .helpers import positive_int_validator, location_validator, archivename_validator, ChunkerParams, Location
from .helpers import PrefixSpec, SortBySpec, HUMAN_SORT_KEYS, FilesCacheMode from .helpers import PrefixSpec, GlobSpec, SortBySpec, HUMAN_SORT_KEYS, FilesCacheMode
from .helpers import BaseFormatter, ItemFormatter, ArchiveFormatter from .helpers import BaseFormatter, ItemFormatter, ArchiveFormatter
from .helpers import format_timedelta, format_file_size, parse_file_size, format_archive from .helpers import format_timedelta, format_file_size, parse_file_size, format_archive
from .helpers import safe_encode, remove_surrogates, bin_to_hex, prepare_dump_dict from .helpers import safe_encode, remove_surrogates, bin_to_hex, prepare_dump_dict
@ -2336,8 +2336,8 @@ class Archiver:
# don't backup the other home directories # don't backup the other home directories
- /home/*\n\n''') - /home/*\n\n''')
helptext['placeholders'] = textwrap.dedent(''' helptext['placeholders'] = textwrap.dedent('''
Repository (or Archive) URLs, ``--prefix`` and ``--remote-path`` values support these Repository (or Archive) URLs, ``--prefix``, ``--glob-archives`` and ``--remote-path``
placeholders: values support these placeholders:
{hostname} {hostname}
The (short) hostname of the machine. The (short) hostname of the machine.
@ -2727,7 +2727,8 @@ class Archiver:
group = filters_group.add_mutually_exclusive_group() group = filters_group.add_mutually_exclusive_group()
group.add_argument('-P', '--prefix', metavar='PREFIX', dest='prefix', type=PrefixSpec, default='', group.add_argument('-P', '--prefix', metavar='PREFIX', dest='prefix', type=PrefixSpec, default='',
help='only consider archive names starting with this prefix.') help='only consider archive names starting with this prefix.')
group.add_argument('-a', '--glob-archives', metavar='GLOB', dest='glob_archives', default=None, group.add_argument('-a', '--glob-archives', metavar='GLOB', dest='glob_archives',
type=GlobSpec, default=None,
help='only consider archive names matching the glob. ' help='only consider archive names matching the glob. '
'sh: rules apply, see "borg help patterns". ' 'sh: rules apply, see "borg help patterns". '
'``--prefix`` and ``--glob-archives`` are mutually exclusive.') '``--prefix`` and ``--glob-archives`` are mutually exclusive.')

View File

@ -685,6 +685,7 @@ def replace_placeholders(text):
PrefixSpec = replace_placeholders PrefixSpec = replace_placeholders
GlobSpec = replace_placeholders
HUMAN_SORT_KEYS = ['timestamp'] + list(ArchiveInfo._fields) HUMAN_SORT_KEYS = ['timestamp'] + list(ArchiveInfo._fields)
HUMAN_SORT_KEYS.remove('ts') HUMAN_SORT_KEYS.remove('ts')