blob: 4a4efca45aebd4be446be12b301d0c34ff216397 [file] [log] [blame]
# Copyright (c) 2020 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
Helper functions used by and
import errno
def write_if_updated(path, s):
Writes 's' as the contents of <out_dir>/<filename>, but only if it
differs from the current contents of the file. This avoids unnecessary
timestamp updates, which trigger documentation rebuilds.
Returns True if the file was updated, False otherwise.
with open(path, "r", encoding="utf-8") as f:
if s ==
return False
except OSError as e:
if e.errno != errno.ENOENT:
with open(path, "w", encoding="utf-8") as f:
return True