aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/CheckMentioned.py4
-rw-r--r--scripts/Dependencies.py30
-rw-r--r--scripts/Face.py4
-rw-r--r--scripts/FileGenerator.py6
-rw-r--r--scripts/GenerateCharacterCategory.py4
-rw-r--r--scripts/ScintillaData.py21
6 files changed, 35 insertions, 34 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/Dependencies.py b/scripts/Dependencies.py
index 135c57ac8..51e332c56 100644
--- a/scripts/Dependencies.py
+++ b/scripts/Dependencies.py
@@ -17,9 +17,10 @@
# Only tested with ASCII file names.
# Copyright 2019 by Neil Hodgson <neilh@scintilla.org>
# The License.txt file describes the conditions under which this software may be distributed.
-# Requires Python 2.7 or later
+# Requires Python 3.6 or later
import codecs, glob, os, sys
+from functools import cache
if __name__ == "__main__":
import FileGenerator
@@ -28,6 +29,7 @@ else:
continuationLineEnd = " \\"
+@cache
def FindPathToHeader(header, includePath):
for incDir in includePath:
relPath = os.path.join(incDir, header)
@@ -35,27 +37,25 @@ def FindPathToHeader(header, includePath):
return relPath
return ""
-fhifCache = {} # Remember the includes in each file. ~5x speed up.
+@cache
def FindHeadersInFile(filePath):
- if filePath not in fhifCache:
- headers = []
- with codecs.open(filePath, "r", "utf-8") as f:
- for line in f:
- if line.strip().startswith("#include"):
- parts = line.split()
- if len(parts) > 1:
- header = parts[1]
- if header[0] != '<': # No system headers
- headers.append(header.strip('"'))
- fhifCache[filePath] = headers
- return fhifCache[filePath]
+ headers = []
+ with codecs.open(filePath, "r", "utf-8") as f:
+ for line in f:
+ if line.strip().startswith("#include"):
+ parts = line.split()
+ if len(parts) > 1:
+ header = parts[1]
+ if header[0] != '<': # No system headers
+ headers.append(header.strip('"'))
+ return headers
def FindHeadersInFileRecursive(filePath, includePath, renames):
headerPaths = []
for header in FindHeadersInFile(filePath):
if header in renames:
header = renames[header]
- relPath = FindPathToHeader(header, includePath)
+ relPath = FindPathToHeader(header, tuple(includePath))
if relPath and relPath not in headerPaths:
headerPaths.append(relPath)
subHeaders = FindHeadersInFileRecursive(relPath, includePath, renames)
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