Skip to content
Snippets Groups Projects
Commit e83c631a authored by Karl-Hermann Wieners's avatar Karl-Hermann Wieners
Browse files

setconfig: fix whitespace by default, add opt-outs

parent 7266344c
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ Tools
* setconfig: make output more similar to mkexp conventions
* remove quotes from section names (may be disabled)
* fix spaces before inline comments when no value is given
* fix spaces at end-of-line and before inline comments (may be disabled)
Release 1.3.1
=============
......
......@@ -37,11 +37,11 @@ command_line.add_argument('--header', '-H', action='append', default=[],
help='append text to header (initial comment)')
command_line.add_argument('--add', '-a', action='append', default=[],
help='add settings from file')
command_line.add_argument('--inline-comments' , '-c', action='store_true',
help='compact white space before inline comments'
' (BETA)')
command_line.add_argument('--trailing-space' , '-t', action='store_true',
help='remove white space at end of lines')
command_line.add_argument('--keep-inline-space' , action='store_true',
help='do not compact white space'
' before inline comments')
command_line.add_argument('--keep-trailing-space', action='store_true',
help='do not remove white space at end of lines')
command_line.add_argument('--keep-section-quotes', action='store_true',
help='do not remove quotes from section names')
......@@ -102,10 +102,12 @@ config_data.write(lines)
lines.seek(0)
for line in io.TextIOWrapper(lines):
if args.inline_comments: line = re.sub(r' = #', r' = #', line)
if args.inline_comments: line = re.sub(r' = (.*?) #', r' = \1 #', line)
if not args.keep_section_quotes: line = re.sub(r'\["(.*?)"\]', r'[\1]', line)
if args.trailing_space:
if not args.keep_inline_space:
line = re.sub(r' = #', r' = #', line)
line = re.sub(r' = (.*?) #', r' = \1 #', line)
if not args.keep_section_quotes:
line = re.sub(r'\["(.*?)"\]', r'[\1]', line)
if not args.keep_trailing_space:
print(line.rstrip())
else:
print(line, end='')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment