summaryrefslogtreecommitdiffstats
path: root/test/fixture/myrewrite.py
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2019-04-28 19:43:43 (GMT)
committerGitHub <noreply@github.com>2019-04-28 19:43:43 (GMT)
commit35e6bbe16a859b42efca4592b435695a530f0717 (patch)
tree5a298b113bb1899e91583866b41eb9c337c0857e /test/fixture/myrewrite.py
parent44c7b81e1a47ff5d4439740b1e929ea723ee1f18 (diff)
parent4ecdcf07580b1bfcd03f7886b6ab9256ee825175 (diff)
downloadSCons-35e6bbe16a859b42efca4592b435695a530f0717.zip
SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.gz
SCons-35e6bbe16a859b42efca4592b435695a530f0717.tar.bz2
Merge pull request #3345 from mwichmann/py38warns4-tests
[wip] Py38warns4 tests
Diffstat (limited to 'test/fixture/myrewrite.py')
-rw-r--r--test/fixture/myrewrite.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/test/fixture/myrewrite.py b/test/fixture/myrewrite.py
index 40bf830..ad46091 100644
--- a/test/fixture/myrewrite.py
+++ b/test/fixture/myrewrite.py
@@ -1,7 +1,17 @@
+r"""
+Phony tool to modify a file in place for testing SCons.
+
+Drops lines that match a pattern. Currently used to test
+ranlib-related behavior without invoking ranlib.
+"""
+
import sys
-line = ('/*' + sys.argv[1] + '*/\n').encode()
-lines = open(sys.argv[2], 'rb').readlines()
-outfile = open(sys.argv[2], 'wb')
-for l in [l for l in lines if l != line]:
- outfile.write(l)
-sys.exit(0)
+
+if __name__ == '__main__':
+ line = ('/*' + sys.argv[1] + '*/\n').encode()
+ with open(sys.argv[2], 'rb') as ifp:
+ lines = [ln for ln in ifp.readlines() if ln != line]
+ with open(sys.argv[2], 'wb') as ofp:
+ for ln in lines:
+ ofp.write(ln)
+ sys.exit(0)