aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-03-15 09:45:15 +1100
committerNeil <nyamatongwe@gmail.com>2023-03-15 09:45:15 +1100
commit481b5651df9bd160d4ff1f1ba471eead61a53252 (patch)
treed1fdb9642eaaef49eab6675dc816a7f7246f93b9 /scripts
parentf5b5b395e2c21c6c8a338a2b2641e3143534589c (diff)
downloadscintilla-mirror-481b5651df9bd160d4ff1f1ba471eead61a53252.tar.gz
Fix some warnings from ruff.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Face.py3
-rw-r--r--scripts/FileGenerator.py28
-rw-r--r--scripts/GenerateCaseConvert.py10
-rw-r--r--scripts/HeaderCheck.py4
-rw-r--r--scripts/ScintillaData.py16
5 files changed, 31 insertions, 30 deletions
diff --git a/scripts/Face.py b/scripts/Face.py
index 21fc67995..58ec47ae8 100644
--- a/scripts/Face.py
+++ b/scripts/Face.py
@@ -5,7 +5,8 @@
# Requires Python 2.7 or later
def sanitiseLine(line):
- if line[-1:] == '\n': line = line[:-1]
+ if line[-1:] == '\n':
+ line = line[:-1]
if line.find("##") != -1:
line = line[:line.find("##")]
line = line.strip()
diff --git a/scripts/FileGenerator.py b/scripts/FileGenerator.py
index bedb16b2f..d35c93955 100644
--- a/scripts/FileGenerator.py
+++ b/scripts/FileGenerator.py
@@ -143,16 +143,16 @@ def UpdateLineInPlistFile(path, key, value):
lines = []
keyCurrent = ""
with codecs.open(path, "rb", "utf-8") as f:
- for l in f.readlines():
- ls = l.strip()
+ for line in f.readlines():
+ ls = line.strip()
if ls.startswith("<key>"):
keyCurrent = ls.replace("<key>", "").replace("</key>", "")
elif ls.startswith("<string>"):
if keyCurrent == key:
- start, tag, rest = l.partition("<string>")
+ start, tag, rest = line.partition("<string>")
_val, etag, end = rest.partition("</string>")
- l = start + tag + value + etag + end
- lines.append(l)
+ line = start + tag + value + etag + end
+ lines.append(line)
contents = "".join(lines)
UpdateFile(path, contents)
@@ -160,13 +160,13 @@ def UpdateLineInFile(path, linePrefix, lineReplace):
lines = []
updated = False
with codecs.open(path, "r", "utf-8") as f:
- for l in f.readlines():
- l = l.rstrip()
- if not updated and l.startswith(linePrefix):
+ for line in f.readlines():
+ line = line.rstrip()
+ if not updated and line.startswith(linePrefix):
lines.append(lineReplace)
updated = True
else:
- lines.append(l)
+ lines.append(line)
if not updated:
print(f"{path}:0: Can't find '{linePrefix}'")
contents = lineEnd.join(lines) + lineEnd
@@ -176,7 +176,7 @@ 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 [l.rstrip('\n') for l in 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.
@@ -194,19 +194,19 @@ def FindSectionInList(lines, markers):
start = -1
end = -1
state = 0
- for i, l in enumerate(lines):
- if markers[0] in l:
+ 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 l:
+ if markers[1] in line:
start = i+1
state = 2
elif state == 2:
- if markers[2] in l:
+ if markers[2] in line:
end = i
state = 3
# Check that section was found
diff --git a/scripts/GenerateCaseConvert.py b/scripts/GenerateCaseConvert.py
index 3c0193ecb..50f992ae6 100644
--- a/scripts/GenerateCaseConvert.py
+++ b/scripts/GenerateCaseConvert.py
@@ -21,11 +21,11 @@ import itertools, string, sys
from FileGenerator import Regenerate
-def contiguousRanges(l, diff):
- # l is s list of lists
+def contiguousRanges(ll, diff):
+ # ll is a list of lists
# group into lists where first element of each element differs by diff
- out = [[l[0]]]
- for s in l[1:]:
+ out = [[ll[0]]]
+ for s in ll[1:]:
if s[0] != out[-1][-1][0] + diff:
out.append([])
out[-1].append(s)
@@ -99,7 +99,7 @@ def groupRanges(symmetrics):
rangeCoverage = list(flatten([range(r[0], r[0]+r[2]*r[3], r[3]) for r in rangeGroups]))
- nonRanges = [(l, u) for l, u, _d in symmetrics if l not in rangeCoverage]
+ nonRanges = [(x, u) for x, u, _d in symmetrics if x not in rangeCoverage]
return rangeGroups, nonRanges
diff --git a/scripts/HeaderCheck.py b/scripts/HeaderCheck.py
index e24cfa1a9..2c953bf30 100644
--- a/scripts/HeaderCheck.py
+++ b/scripts/HeaderCheck.py
@@ -16,11 +16,11 @@ def HeaderFromIncludeLine(s):
def ExtractHeaders(file):
with file.open(encoding="cp437") as infile:
- return [HeaderFromIncludeLine(l) for l in infile if IsHeader(l)]
+ return [HeaderFromIncludeLine(h) for h in infile if IsHeader(h)]
def ExtractWithPrefix(file, prefix):
with file.open(encoding="cp437") as infile:
- return [l.strip()[len(prefix):] for l in infile if l.startswith(prefix)]
+ return [s.strip()[len(prefix):] for s in infile if s.startswith(prefix)]
def ExcludeName(name, excludes):
return any(exclude in name for exclude in excludes)
diff --git a/scripts/ScintillaData.py b/scripts/ScintillaData.py
index 857da7dd5..044ecfb01 100644
--- a/scripts/ScintillaData.py
+++ b/scripts/ScintillaData.py
@@ -25,15 +25,15 @@ def FindCredits(historyFile, removeLinks=True):
credits = []
stage = 0
with historyFile.open(encoding="utf-8") as f:
- for l in f.readlines():
- l = l.strip()
- if stage == 0 and l == "<table>":
+ for line in f.readlines():
+ line = line.strip()
+ if stage == 0 and line == "<table>":
stage = 1
- elif stage == 1 and l == "</table>":
+ elif stage == 1 and line == "</table>":
stage = 2
- if stage == 1 and l.startswith("<td>"):
- credit = l[4:-5]
- if removeLinks and "<a" in l:
+ if stage == 1 and line.startswith("<td>"):
+ credit = line[4:-5]
+ if removeLinks and "<a" in line:
title, _a, rest = credit.partition("<a href=")
urlplus, _bracket, end = rest.partition(">")
name = end.split("<")[0]
@@ -54,7 +54,7 @@ class ScintillaData:
self.versionCommad = self.versionDotted.replace(".", ", ") + ', 0'
with (scintillaRoot / "doc" / "index.html").open() as f:
- self.dateModified = [l for l in f.readlines() if "Date.Modified" in l]\
+ self.dateModified = [d for d in f.readlines() if "Date.Modified" in d]\
[0].split('\"')[3]
# 20130602
# index.html, SciTE.html