aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2026-03-19 12:00:33 +1100
committerNeil <nyamatongwe@gmail.com>2026-03-19 12:00:33 +1100
commit69afca435b271b42a341730802467bacf88fa444 (patch)
treef1a7c127ab122429256a57a4d1955ae5ee2e7884 /scripts
parent7c601c401a26d203d191b198a52e745f6a67c1fe (diff)
downloadscintilla-mirror-69afca435b271b42a341730802467bacf88fa444.tar.gz
Remove unnecessary readlines and make FindCredits same as SciTE.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/CheckMentioned.py4
-rw-r--r--scripts/Face.py4
-rw-r--r--scripts/FileGenerator.py6
-rw-r--r--scripts/GenerateCharacterCategory.py4
-rw-r--r--scripts/ScintillaData.py21
5 files changed, 20 insertions, 19 deletions
diff --git a/scripts/CheckMentioned.py b/scripts/CheckMentioned.py
index 1e5f6c393..b6d52293e 100644
--- a/scripts/CheckMentioned.py
+++ b/scripts/CheckMentioned.py
@@ -35,13 +35,13 @@ def depunctuate(s):
symbols = {}
with open(incFileName, "rt") as incFile:
- for line in incFile.readlines():
+ for line in incFile:
if line.startswith("#define"):
identifier = line.split()[1]
symbols[identifier] = 0
with open(docFileName, "rt") as docFile:
- for line in docFile.readlines():
+ for line in docFile:
for word in depunctuate(line).split():
if word in symbols.keys():
symbols[word] = 1
diff --git a/scripts/Face.py b/scripts/Face.py
index 9814115f0..0278f5ac2 100644
--- a/scripts/Face.py
+++ b/scripts/Face.py
@@ -2,7 +2,7 @@
# Face.py - module for reading and parsing Scintilla.iface file
# Implemented 2000 by Neil Hodgson neilh@scintilla.org
# Released to the public domain.
-# Requires Python 2.7 or later
+# Requires Python 3.6 or later
def sanitiseLine(line):
line = line.rstrip('\n')
@@ -72,7 +72,7 @@ class Face:
currentComment = []
currentCommentFinished = 0
file = open(name)
- for line in file.readlines():
+ for line in file:
line = sanitiseLine(line)
if line:
if line[0] == "#":
diff --git a/scripts/FileGenerator.py b/scripts/FileGenerator.py
index f798e1d6b..f596e9cbe 100644
--- a/scripts/FileGenerator.py
+++ b/scripts/FileGenerator.py
@@ -4,7 +4,7 @@
# Generate or regenerate source files based on comments in those files.
# May be modified in-place or a template may be generated into a complete file.
-# Requires Python 2.7 or later
+# Requires Python 3.6 or later
# The files are copied to a string apart from sections between a
# ++Autogenerated comment and a --Autogenerated comment which is
# generated by the CopyWithInsertion function. After the whole string is
@@ -143,7 +143,7 @@ def UpdateLineInPlistFile(path, key, value):
lines = []
keyCurrent = ""
with codecs.open(path, "rb", "utf-8") as f:
- for line in f.readlines():
+ for line in f:
ls = line.strip()
if ls.startswith("<key>"):
keyCurrent = ls.replace("<key>", "").replace("</key>", "")
@@ -160,7 +160,7 @@ def UpdateLineInFile(path, linePrefix, lineReplace):
lines = []
updated = False
with codecs.open(path, "r", "utf-8") as f:
- for line in f.readlines():
+ for line in f:
line = line.rstrip()
if not updated and line.startswith(linePrefix):
lines.append(lineReplace)
diff --git a/scripts/GenerateCharacterCategory.py b/scripts/GenerateCharacterCategory.py
index 806dea2fe..1080cceed 100644
--- a/scripts/GenerateCharacterCategory.py
+++ b/scripts/GenerateCharacterCategory.py
@@ -2,7 +2,7 @@
# Script to generate scintilla/src/CharacterCategoryMap.cxx and lexilla/lexlib/CharacterCategory.cxx
# from Python's Unicode data
# Should be run rarely when a Python with a new version of Unicode data is available.
-# Requires Python 3.3 or later
+# Requires Python 3.6 or later
# Should not be run with old versions of Python.
import pathlib, platform, sys, unicodedata
@@ -11,7 +11,7 @@ from FileGenerator import Regenerate
def findCategories(filename):
with filename.open(encoding="UTF-8") as infile:
- lines = [x.strip() for x in infile.readlines() if "\tcc" in x]
+ lines = [x.strip() for x in infile if "\tcc" in x]
values = "".join(lines).replace(" ","").split(",")
print("Categrories:", values)
return [v[2:] for v in values]
diff --git a/scripts/ScintillaData.py b/scripts/ScintillaData.py
index 55534306b..d57898e5e 100644
--- a/scripts/ScintillaData.py
+++ b/scripts/ScintillaData.py
@@ -25,19 +25,20 @@
import datetime, pathlib, sys
def FindCredits(historyFile, removeLinks=True):
+ """ Return a list of contributors in a history file. """
credits = []
stage = 0
with historyFile.open(encoding="utf-8") as f:
- for line in f.readlines():
- line = line.strip()
- if stage == 0 and line == "<table>":
+ for line in f:
+ s = line.strip()
+ if stage == 0 and s == "<table>":
stage = 1
- elif stage == 1 and line == "</table>":
+ elif stage == 1 and s == "</table>":
stage = 2
- if stage == 1 and line.startswith("<td>"):
- credit = line[4:-5]
- if removeLinks and "<a" in line:
- title, _a, rest = credit.partition("<a href=")
+ if stage == 1 and s.startswith("<td>"):
+ credit = s[4:-5]
+ if removeLinks and "<a" in s:
+ title, _, rest = credit.partition("<a href=")
urlplus, _bracket, end = rest.partition(">")
name = end.split("<")[0]
url = urlplus[1:-1]
@@ -57,14 +58,14 @@ class ScintillaData:
self.versionCommad = self.versionDotted.replace(".", ", ") + ', 0'
with (scintillaRoot / "doc" / "index.html").open() as f:
- self.dateModified = [d for d in f.readlines() if "Date.Modified" in d]\
+ self.dateModified = [d for d in f if "Date.Modified" in d]\
[0].split('\"')[3]
# 20130602
# index.html, SciTE.html
dtModified = datetime.datetime.strptime(self.dateModified, "%Y%m%d")
self.yearModified = self.dateModified[0:4]
monthModified = dtModified.strftime("%B")
- dayModified = "%d" % dtModified.day
+ dayModified = f"{dtModified.day}"
self.mdyModified = monthModified + " " + dayModified + " " + self.yearModified
# May 22 2013
# index.html, SciTE.html