diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-03-04 17:02:31 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-03-04 17:11:26 -0500 |
commit | 4340bf34faca7eed8076ba4c388fbe15355f2183 (patch) | |
tree | 6082548a6cb79091d1059a73e7b3b9f59657f6d9 /test cases | |
parent | 76df995ba69ef5d790462856b3edbd42b28b906a (diff) | |
download | meson-4340bf34faca7eed8076ba4c388fbe15355f2183.zip meson-4340bf34faca7eed8076ba4c388fbe15355f2183.tar.gz meson-4340bf34faca7eed8076ba4c388fbe15355f2183.tar.bz2 |
various python neatness cleanups
All changes were created by running
"pyupgrade --py3-only --keep-percent-format"
and committing the results. I have not touched string formatting for
now.
- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
Diffstat (limited to 'test cases')
12 files changed, 7 insertions, 12 deletions
diff --git a/test cases/common/106 generatorcustom/catter.py b/test cases/common/106 generatorcustom/catter.py index 198fa98..c272672 100755 --- a/test cases/common/106 generatorcustom/catter.py +++ b/test cases/common/106 generatorcustom/catter.py @@ -8,7 +8,7 @@ inputs = sys.argv[1:-1] with open(output, 'w') as ofile: ofile.write('#pragma once\n') for i in inputs: - with open(i, 'r') as ifile: + with open(i) as ifile: content = ifile.read() ofile.write(content) ofile.write('\n') diff --git a/test cases/common/106 generatorcustom/gen.py b/test cases/common/106 generatorcustom/gen.py index c1e34ed..1464008 100755 --- a/test cases/common/106 generatorcustom/gen.py +++ b/test cases/common/106 generatorcustom/gen.py @@ -5,7 +5,7 @@ import sys ifile = sys.argv[1] ofile = sys.argv[2] -with open(ifile, 'r') as f: +with open(ifile) as f: resname = f.readline().strip() templ = 'const char %s[] = "%s";\n' diff --git a/test cases/common/126 configure file in generator/src/gen.py b/test cases/common/126 configure file in generator/src/gen.py index 99b7cdd..426d0b7 100755 --- a/test cases/common/126 configure file in generator/src/gen.py +++ b/test cases/common/126 configure file in generator/src/gen.py @@ -5,7 +5,7 @@ import sys ifile = sys.argv[1] ofile = sys.argv[2] -with open(ifile, 'r') as f: +with open(ifile) as f: resval = f.readline().strip() templ = '#define RESULT (%s)\n' diff --git a/test cases/common/14 configure file/file_contains.py b/test cases/common/14 configure file/file_contains.py index 25634f5..409f09c 100644 --- a/test cases/common/14 configure file/file_contains.py +++ b/test cases/common/14 configure file/file_contains.py @@ -11,7 +11,7 @@ def main(): text = args.text[0] - with open(args.file[0], 'r', encoding='utf-8') as f: + with open(args.file[0], encoding='utf-8') as f: for line in f: if line.strip() == text: return 0 diff --git a/test cases/common/52 run target/fakeburner.py b/test cases/common/52 run target/fakeburner.py index da3d0ac..8b1f353 100755 --- a/test cases/common/52 run target/fakeburner.py +++ b/test cases/common/52 run target/fakeburner.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import sys diff --git a/test cases/common/71 external test program/mytest.py b/test cases/common/71 external test program/mytest.py index 9947773..fee94e0 100755 --- a/test cases/common/71 external test program/mytest.py +++ b/test cases/common/71 external test program/mytest.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import sys diff --git a/test cases/common/72 ctarget dependency/gen1.py b/test cases/common/72 ctarget dependency/gen1.py index 0fa6ea1..dbadb6d 100755 --- a/test cases/common/72 ctarget dependency/gen1.py +++ b/test cases/common/72 ctarget dependency/gen1.py @@ -6,7 +6,7 @@ import time, sys # is missing. time.sleep(0.5) -with open(sys.argv[1], 'r') as f: +with open(sys.argv[1]) as f: contents = f.read() with open(sys.argv[2], 'w') as f: f.write(contents) diff --git a/test cases/common/72 ctarget dependency/gen2.py b/test cases/common/72 ctarget dependency/gen2.py index b087b02..dc6525b 100755 --- a/test cases/common/72 ctarget dependency/gen2.py +++ b/test cases/common/72 ctarget dependency/gen2.py @@ -6,5 +6,5 @@ from glob import glob files = glob(os.path.join(sys.argv[1], '*.tmp')) assert(len(files) == 1) -with open(files[0], 'r') as ifile, open(sys.argv[2], 'w') as ofile: +with open(files[0]) as ifile, open(sys.argv[2], 'w') as ofile: ofile.write(ifile.read()) diff --git a/test cases/common/96 manygen/subdir/manygen.py b/test cases/common/96 manygen/subdir/manygen.py index 32ea63c..c40cc2e 100755 --- a/test cases/common/96 manygen/subdir/manygen.py +++ b/test cases/common/96 manygen/subdir/manygen.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function # Generates a static library, object file, source # file and a header file. diff --git a/test cases/unit/11 cross prog/some_cross_tool.py b/test cases/unit/11 cross prog/some_cross_tool.py index 4a473e2..6c01b1a 100755 --- a/test cases/unit/11 cross prog/some_cross_tool.py +++ b/test cases/unit/11 cross prog/some_cross_tool.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import print_function print('cross') diff --git a/test cases/unit/11 cross prog/sometool.py b/test cases/unit/11 cross prog/sometool.py index 2ac5680..06bcdc8 100755 --- a/test cases/unit/11 cross prog/sometool.py +++ b/test cases/unit/11 cross prog/sometool.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import print_function print('native') diff --git a/test cases/windows/12 resources with custom targets/res/gen-res.py b/test cases/windows/12 resources with custom targets/res/gen-res.py index 2feb02f..e5ef6b1 100755 --- a/test cases/windows/12 resources with custom targets/res/gen-res.py +++ b/test cases/windows/12 resources with custom targets/res/gen-res.py @@ -2,5 +2,5 @@ import sys -with open(sys.argv[1], 'r') as infile, open(sys.argv[2], 'w') as outfile: +with open(sys.argv[1]) as infile, open(sys.argv[2], 'w') as outfile: outfile.write(infile.read().format(icon=sys.argv[3])) |