MCPcopy
hub / github.com/saltstack/salt / update

Method update

salt/modules/ini_manage.py:487–526  ·  view source on GitHub ↗
(self, update_dict)

Source from the content-addressed store, hash-verified

485 super().update({key: value})
486
487 def update(self, update_dict):
488 changes = {}
489 for key, value in update_dict.items():
490 # Ensure the value is either a _Section or a string
491 if isinstance(value, (dict, OrderedDict)):
492 sect = _Section(
493 name=key,
494 inicontents="",
495 separator=self.sep,
496 commenter=self.com,
497 no_spaces=self.no_spaces,
498 )
499 sect.update(value)
500 value = sect
501 value_plain = value.as_dict()
502 else:
503 value = str(value)
504 value_plain = value
505
506 if key not in self:
507 changes.update({key: {"before": None, "after": value_plain}})
508 # If it's not a section, it may already exist as a
509 # commented-out key/value pair
510 if not isinstance(value, _Section):
511 self._uncomment_if_commented(key)
512
513 super().update({key: value})
514 else:
515 curr_value = self.get(key, None)
516 if isinstance(curr_value, _Section):
517 sub_changes = curr_value.update(value)
518 if sub_changes:
519 changes.update({key: sub_changes})
520 else:
521 if curr_value != value:
522 changes.update(
523 {key: {"before": curr_value, "after": value_plain}}
524 )
525 super().update({key: value})
526 return changes
527
528 def gen_ini(self):
529 yield f"{os.linesep}[{self.name}]{os.linesep}"

Callers 15

refreshMethod · 0.95
sign_remote_certificateFunction · 0.45
get_signing_policyFunction · 0.45
create_certificateFunction · 0.45
optionFunction · 0.45
mergeFunction · 0.45
_explore_pathFunction · 0.45
connectFunction · 0.45
fqdnsFunction · 0.45
run_taskFunction · 0.45
get_enabledFunction · 0.45
get_disabledFunction · 0.45

Calls 5

_SectionClass · 0.85
itemsMethod · 0.45
as_dictMethod · 0.45
getMethod · 0.45

Tested by 1

opts_pkgFunction · 0.36