Fix generated configuration to also include a "keep_daily" value so pruning works out of the box.
This commit is contained in:
parent
984702b3b2
commit
746428ed44
3 changed files with 17 additions and 4 deletions
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
|||
1.2.6
|
||||
* Fix generated configuration to also include a "keep_daily" value so pruning works out of the
|
||||
box.
|
||||
|
||||
1.2.5
|
||||
* #57: When generating sample configuration with generate-borgmatic-config, comment out all
|
||||
optional configuration so as to streamline the initial configuration process.
|
||||
|
|
|
@ -55,6 +55,10 @@ def _comment_out_line(line):
|
|||
return '#'.join((one_indent, line[INDENT:]))
|
||||
|
||||
|
||||
REQUIRED_KEYS = {'source_directories', 'repositories', 'keep_daily'}
|
||||
REQUIRED_SECTION_NAMES = {'location', 'retention'}
|
||||
|
||||
|
||||
def _comment_out_optional_configuration(rendered_config):
|
||||
'''
|
||||
Post-process a rendered configuration string to comment out optional key/values. The idea is
|
||||
|
@ -68,12 +72,17 @@ def _comment_out_optional_configuration(rendered_config):
|
|||
required = False
|
||||
|
||||
for line in rendered_config.split('\n'):
|
||||
key = line.strip().split(':')[0]
|
||||
|
||||
if key in REQUIRED_SECTION_NAMES:
|
||||
lines.append(line)
|
||||
continue
|
||||
|
||||
# Upon encountering a required configuration option, skip commenting out lines until the
|
||||
# next blank line.
|
||||
stripped_line = line.strip()
|
||||
if stripped_line in {'source_directories:', 'repositories:'} or line == 'location:':
|
||||
if key in REQUIRED_KEYS:
|
||||
required = True
|
||||
elif not stripped_line:
|
||||
elif not key:
|
||||
required = False
|
||||
|
||||
lines.append(_comment_out_line(line) if not required else line)
|
||||
|
|
2
setup.py
2
setup.py
|
@ -1,7 +1,7 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
VERSION = '1.2.5'
|
||||
VERSION = '1.2.6'
|
||||
|
||||
|
||||
setup(
|
||||
|
|
Loading…
Reference in a new issue