diff column_maker.py @ 8:02026300aa45 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/column_maker commit 276e05a2c72c031318eef8c57deebbbde822b538"
author iuc
date Tue, 09 Mar 2021 18:33:10 +0000
parents 427903d47026
children 6595517c2dd8
line wrap: on
line diff
--- a/column_maker.py	Wed Feb 24 05:20:07 2021 +0000
+++ b/column_maker.py	Tue Mar 09 18:33:10 2021 +0000
@@ -10,14 +10,14 @@
 import json
 import re
 import sys
-# functions that may be used in the compute expression
+# Functions that may be used in the compute expression
 from math import (  # noqa: F401
     ceil,
     exp,
     floor,
     log,
     log10,
-    sqrt
+    sqrt,
 )
 
 from numpy import format_float_positional  # noqa: F401
@@ -141,15 +141,15 @@
 try:
     exec(code)
 except Exception as e:
-    out.close()
     if str(e).startswith('invalid syntax'):
         valid_expr = False
         sys.exit('Expression "%s" likely invalid. See tool tips, syntax and examples.' % expr)
     else:
         sys.exit(str(e))
+finally:
+    out.close()
 
 if valid_expr:
-    out.close()
     valid_lines = total_lines - skipped_lines
     print('Creating column %d with expression %s' % (in_columns + 1, expr))
     if valid_lines > 0: