Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master]WIP: Add no_spaces option to remove spaces around separator in ini file #60081

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions salt/modules/ini_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,14 @@ def ini_odict2dict(odict):


class _Section(OrderedDict):
def __init__(self, name, inicontents="", separator="=", commenter="#"):
def __init__(self, name, inicontents="", separator="=", commenter="#", no_spaces=False):
super().__init__(self)
self.name = name
self.inicontents = inicontents
self.sep = separator
self.com = commenter
if not no_spaces =
self.sep = ' ' + self.sep + ' '

opt_regx_prefix = r"(\s*)(.+?)\s*"
opt_regx_suffix = r"\s*(.*)\s*"
Expand Down Expand Up @@ -517,11 +519,10 @@ def gen_ini(self):
elif isinstance(value, _Section):
sections_dict.update({name: value})
# Key / Value pairs
# Adds spaces between the separator
else:
yield "{}{}{}{}".format(
name,
f" {self.sep} " if self.sep != " " else self.sep,
self.sep,
value,
os.linesep,
)
Expand Down
Loading