diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-28 01:51:22 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-09-28 01:51:22 +0200 |
| commit | e429ded62dd5b9f963222764c62e96a560ca6bdf (patch) | |
| tree | d6a04b82970ce45dee8c958b274dd055a144b24c /kconfiglib.py | |
| parent | 061757589578d6e78e444c7ab6324a159ace7600 (diff) | |
Get rid of _comment()
Can be handled inline in a nicer way, especially with writelines().
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 3368bc0..ca8b099 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -528,10 +528,12 @@ class Config(object): for item in self._top_block: item._add_config_strings(add_fn) - # Write header and configuration with open(filename, "w") as f: + # Write header if header is not None: - f.write(_comment(header) + "\n") + f.writelines(["#" + line + for line in (header + "\n").splitlines(True)]) + # Write configuration f.writelines(config_strings) def eval(self, s): @@ -3454,15 +3456,6 @@ def _lines(*args): between them.""" return "\n".join(args) -def _comment(s): - """Returns a new string with "#" inserted before each line in 's'.""" - if not s: - return "#" - res = "".join(["#" + line for line in s.splitlines(True)]) - if s.endswith("\n"): - return res + "#" - return res - def _stderr_msg(msg, filename, linenr): if filename is not None: sys.stderr.write("{}:{}: ".format(filename, linenr)) |
