texlive[71644] Build/source/texk/web2c/tests/fix-changefile-lines.py:
commits+ascherer at tug.org
commits+ascherer at tug.org
Fri Jun 28 23:47:10 CEST 2024
Revision: 71644
https://tug.org/svn/texlive?view=revision&revision=71644
Author: ascherer
Date: 2024-06-28 23:47:10 +0200 (Fri, 28 Jun 2024)
Log Message:
-----------
Merge 'with' and 'try..except'.
No need to store the file handles in 'self'.
Modified Paths:
--------------
trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py
Modified: trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py
===================================================================
--- trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py 2024-06-28 21:33:20 UTC (rev 71643)
+++ trunk/Build/source/texk/web2c/tests/fix-changefile-lines.py 2024-06-28 21:47:10 UTC (rev 71644)
@@ -50,13 +50,12 @@
self.part_cnt = 0
self.section_cnt = 0
try:
- self._web_file = open(web_file, "r")
+ with open(web_file, "r") as file:
+ self._web_lines = [line.rstrip() for line in file]
except OSError:
eprint(f"Could not open {web_file}")
print(USAGE)
sys.exit(1)
- with self._web_file:
- self._web_lines = [line.rstrip() for line in self._web_file]
def next_line(self):
"""Returns the triple of current part, section and line numbers, as
@@ -105,13 +104,12 @@
self._chunk_start = None
self._match_lines = None
try:
- self._change_file = open(change_file, "r")
+ with open(change_file, "r") as file:
+ self._lines = [line.rstrip() for line in file]
except OSError:
eprint(f"Could not open {change_file}")
print(USAGE)
sys.exit(1)
- with self._change_file:
- self._lines = [line.rstrip() for line in self._change_file]
def advance_to_next_chunk(self):
"""Find the next change chunk. Store where it starts and
More information about the tex-live-commits
mailing list.