Add Variables.defualted attribute
[scons.git] / test / fixture / myrewrite.py
blobf331558824bef20127738275e472e9117247694d
1 # SPDX-License-Identifier: MIT
3 # Copyright The SCons Foundation
5 r"""
6 Phony tool to modify a file in place for testing SCons.
8 Drops lines that match a pattern. Currently used to test
9 ranlib and ar behavior without actually invoking those tools.
10 """
12 import sys
14 def rewrite():
15 line = ('/*' + sys.argv[1] + '*/\n').encode('utf-8')
16 with open(sys.argv[2], 'rb') as ifp:
17 lines = [ln for ln in ifp if ln != line]
18 with open(sys.argv[2], 'wb') as ofp:
19 ofp.writelines(lines)
22 if __name__ == '__main__':
23 rewrite()
24 sys.exit(0)