MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / _write_if_changed

Method _write_if_changed

scripts/kconfig/kconfiglib.py:2331–2348  ·  view source on GitHub ↗
(self, filename, contents)

Source from the content-addressed store, hash-verified

2329 self._reuse_tokens = True
2330
2331 def _write_if_changed(self, filename, contents):
2332 # Writes 'contents' into 'filename', but only if it differs from the
2333 # current contents of the file.
2334 #
2335 # Another variant would be write a temporary file on the same
2336 # filesystem, compare the files, and rename() the temporary file if it
2337 # differs, but it breaks stuff like write_config("/dev/null"), which is
2338 # used out there to force evaluation-related warnings to be generated.
2339 # This simple version is pretty failsafe and portable.
2340 #
2341 # Returns True if the file has changed and is updated, and False
2342 # otherwise.
2343
2344 if self._contents_eq(filename, contents):
2345 return False
2346 with self._open(filename, "w") as f:
2347 f.write(contents)
2348 return True
2349
2350 def _contents_eq(self, filename, contents):
2351 # Returns True if the contents of 'filename' is 'contents' (a string),

Callers 4

write_splitconfMethod · 0.95
write_autoconfMethod · 0.95
write_min_configMethod · 0.95
_write_old_valsMethod · 0.95

Calls 3

_contents_eqMethod · 0.95
_openMethod · 0.95
writeMethod · 0.45

Tested by

no test coverage detected