diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2015-09-21 10:45:47 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2015-09-21 10:45:47 +1000 |
commit | 031dd0ed3f6e1d0054361219a45d306627b84e48 (patch) | |
tree | 5af5a7d869d9304b54f6fc2750c28c7bb7dae48d /scripts/FileGenerator.py | |
parent | f40428e124d088e5b66458c879d0881023a1f5c8 (diff) | |
download | scintilla-mirror-031dd0ed3f6e1d0054361219a45d306627b84e48.tar.gz |
Automate updating of version numbers in the Scintilla framework.
Diffstat (limited to 'scripts/FileGenerator.py')
-rw-r--r-- | scripts/FileGenerator.py | 19 |
1 files changed, 19 insertions, 0 deletions
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("<key>"): + keyCurrent = ls.replace("<key>", "").replace("</key>", "") + elif ls.startswith("<string>"): + if keyCurrent == key: + start, tag, rest = l.partition("<string>") + val, etag, end = rest.partition("</string>") + l = start + tag + value + etag + end + lines.append(l) + contents = "".join(lines) + UpdateFile(path, contents) + def UpdateLineInFile(path, linePrefix, lineReplace): lines = [] updated = False |