diff options
author | Neil <nyamatongwe@gmail.com> | 2023-11-20 12:28:25 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-11-20 12:28:25 +1100 |
commit | 1348727852f4f9d517245ad9b20bf3c056af47ec (patch) | |
tree | 0ec5fe7276388a4e9cb4dfbcb526c30ca9e97430 /scripts/FileGenerator.py | |
parent | 6bbf1635dbdd6bee83202593b9f9a27e58a2a2e1 (diff) | |
download | scintilla-mirror-1348727852f4f9d517245ad9b20bf3c056af47ec.tar.gz |
Move ReadFileAsList and FindSectionInList from Scintilla to Lexilla as Lexilla
is the only user of these functions.
Diffstat (limited to 'scripts/FileGenerator.py')
-rw-r--r-- | scripts/FileGenerator.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/scripts/FileGenerator.py b/scripts/FileGenerator.py index d35c93955..f798e1d6b 100644 --- a/scripts/FileGenerator.py +++ b/scripts/FileGenerator.py @@ -172,50 +172,12 @@ def UpdateLineInFile(path, linePrefix, lineReplace): contents = lineEnd.join(lines) + lineEnd UpdateFile(path, contents) -def ReadFileAsList(path): - """Read all the lnes in the file and return as a list of strings without line ends. - """ - with codecs.open(path, "r", "utf-8") as f: - return [line.rstrip('\n') for line in f] - def UpdateFileFromLines(path, lines, lineEndToUse): """Join the lines with the lineEndToUse then update file if the result is different. """ contents = lineEndToUse.join(lines) + lineEndToUse UpdateFile(path, contents) -def FindSectionInList(lines, markers): - """Find a section defined by an initial start marker, an optional secondary - marker and an end marker. - The section is between the secondary/initial start and the end. - Report as a slice object so the section can be extracted or replaced. - Raises an exception if the markers can't be found. - """ - start = -1 - end = -1 - state = 0 - for i, line in enumerate(lines): - if markers[0] in line: - if markers[1]: - state = 1 - else: - start = i+1 - state = 2 - elif state == 1: - if markers[1] in line: - start = i+1 - state = 2 - elif state == 2: - if markers[2] in line: - end = i - state = 3 - # Check that section was found - if start == -1: - raise Exception("Could not find start marker(s) |" + markers[0] + "|" + markers[1] + "|") - if end == -1: - raise Exception("Could not find end marker " + markers[2]) - return slice(start, end) - def ReplaceREInFile(path, match, replace, count=1): with codecs.open(path, "r", "utf-8") as f: contents = f.read() |