From b3f9c327aa225b38a2433e313d2772d9fd1e54bc Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Mon, 21 Sep 2015 10:45:47 +1000 Subject: Automate updating of version numbers in the Scintilla framework. --- scripts/FileGenerator.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'scripts/FileGenerator.py') diff --git a/scripts/FileGenerator.py b/scripts/FileGenerator.py index 01a79bf99..e2750ebe0 100644 --- a/scripts/FileGenerator.py +++ b/scripts/FileGenerator.py @@ -137,6 +137,25 @@ def Regenerate(filename, commentPrefix, *lists): """ Generate(filename, filename, commentPrefix, *lists) +def UpdateLineInPlistFile(path, key, value): + """Replace a single string value preceded by 'key' in an XML plist file. + """ + lines = [] + keyCurrent = "" + with codecs.open(path, "rb", "utf-8") as f: + for l in f.readlines(): + ls = l.strip() + if ls.startswith(""): + keyCurrent = ls.replace("", "").replace("", "") + elif ls.startswith(""): + if keyCurrent == key: + start, tag, rest = l.partition("") + val, etag, end = rest.partition("") + l = start + tag + value + etag + end + lines.append(l) + contents = "".join(lines) + UpdateFile(path, contents) + def UpdateLineInFile(path, linePrefix, lineReplace): lines = [] updated = False -- cgit v1.2.3