[Piglit] [PATCH 18/45] gen_shader_bit_encoding_tests.py: Use with and print_function

Dylan Baker baker.dylan.c at gmail.com
Wed Nov 12 15:46:00 PST 2014


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_shader_bit_encoding_tests.py | 29 ++++++++++++------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py
index 1b2f028..5cfb274 100644
--- a/generated_tests/gen_shader_bit_encoding_tests.py
+++ b/generated_tests/gen_shader_bit_encoding_tests.py
@@ -21,6 +21,7 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
+from __future__ import print_function
 import struct
 import os
 from operator import neg
@@ -148,7 +149,7 @@ def main():
                         'built-in-functions',
                         "{0}-{1}{2}.shader_test".format(execution_stage, func,
                                                         modifier_name))
-                    print filename
+                    print(filename)
 
                     dirname = os.path.dirname(filename)
                     if not os.path.exists(dirname):
@@ -159,19 +160,19 @@ def main():
                     elif in_modifier_func == 'neg_abs':
                         in_modifier_func = '-abs'
 
-                    f = open(filename, 'w')
-                    f.write(TEMPLATE.render(version=version,
-                                            extensions=extensions,
-                                            execution_stage=execution_stage,
-                                            func=func,
-                                            modifier_func=modifier_func,
-                                            in_modifier_func=in_modifier_func,
-                                            in_func=in_func,
-                                            out_func=out_func,
-                                            input_type=input_type,
-                                            output_type=output_type,
-                                            test_data=test_data))
-                    f.close()
+                    with open(filename, 'w') as f:
+                        f.write(TEMPLATE.render(
+                            version=version,
+                            extensions=extensions,
+                            execution_stage=execution_stage,
+                            func=func,
+                            modifier_func=modifier_func,
+                            in_modifier_func=in_modifier_func,
+                            in_func=in_func,
+                            out_func=out_func,
+                            input_type=input_type,
+                            output_type=output_type,
+                            test_data=test_data))
 
 
 if __name__ == '__main__':
-- 
2.1.3



More information about the Piglit mailing list