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
|
1.2.5
|
||||||
* #57: When generating sample configuration with generate-borgmatic-config, comment out all
|
* #57: When generating sample configuration with generate-borgmatic-config, comment out all
|
||||||
optional configuration so as to streamline the initial configuration process.
|
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:]))
|
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):
|
def _comment_out_optional_configuration(rendered_config):
|
||||||
'''
|
'''
|
||||||
Post-process a rendered configuration string to comment out optional key/values. The idea is
|
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
|
required = False
|
||||||
|
|
||||||
for line in rendered_config.split('\n'):
|
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
|
# Upon encountering a required configuration option, skip commenting out lines until the
|
||||||
# next blank line.
|
# next blank line.
|
||||||
stripped_line = line.strip()
|
if key in REQUIRED_KEYS:
|
||||||
if stripped_line in {'source_directories:', 'repositories:'} or line == 'location:':
|
|
||||||
required = True
|
required = True
|
||||||
elif not stripped_line:
|
elif not key:
|
||||||
required = False
|
required = False
|
||||||
|
|
||||||
lines.append(_comment_out_line(line) if not required else line)
|
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
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
VERSION = '1.2.5'
|
VERSION = '1.2.6'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
Loading…
Reference in a new issue