From a5ed336d3f557177727e18af44b17890ea980a13 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 1 Aug 2018 11:15:49 -0500 Subject: [PATCH 1/2] Pylint dagrt.utils --- dagrt/utils.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dagrt/utils.py b/dagrt/utils.py index b69d107..f9a7677 100644 --- a/dagrt/utils.py +++ b/dagrt/utils.py @@ -49,7 +49,7 @@ def get_variables(expr, include_function_symbols=False): def is_state_variable(var): """Check if the given name corresponds to a state variable.""" - if var == '' or var == '
': + if var in ('', '
'): return True elif (var.startswith('') or var.startswith('

') @@ -143,9 +143,9 @@ class TemporaryDirectory(object): name = None _closed = False - def __init__(self, suffix="", prefix="tmp", dir=None): + def __init__(self, suffix="", prefix="tmp", dirname=None): from tempfile import mkdtemp - self.name = mkdtemp(suffix, prefix, dir) + self.name = mkdtemp(suffix, prefix, dirname) def __repr__(self): return "<{} {!r}>".format(self.__class__.__name__, self.name) @@ -157,12 +157,7 @@ class TemporaryDirectory(object): import warnings if self.name and not self._closed: from shutil import rmtree - try: - rmtree(self.name) - except (TypeError, AttributeError) as ex: - if "None" not in '%s' % (ex,): - raise - self._rmtree(self.name) + rmtree(self.name) self._closed = True if _warn and warnings.warn: warnings.warn("Implicitly cleaning up {!r}".format(self)) @@ -179,7 +174,10 @@ class TemporaryDirectory(object): # {{{ run_fortran -def run_fortran(sources, fortran_options=[]): +def run_fortran(sources, fortran_options=None): + if fortran_options is None: + fortran_options = [] + from os.path import join with TemporaryDirectory() as tmpdir: -- GitLab From b85c7ddb04fcef5330c84cc7dbe7d7584078cd5f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 1 Aug 2018 11:16:19 -0500 Subject: [PATCH 2/2] dagrt.utils.run_fortran: read fortran compiler from env var --- dagrt/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dagrt/utils.py b/dagrt/utils.py index f9a7677..e0ddb55 100644 --- a/dagrt/utils.py +++ b/dagrt/utils.py @@ -188,9 +188,10 @@ def run_fortran(sources, fortran_options=None): with open(join(tmpdir, name), "w") as srcf: srcf.write(contents) + import os from subprocess import check_call, Popen, PIPE check_call( - ["gfortran", + [os.environ.get("FC", "gfortran"), "-Wall", "-Wno-unused-dummy-argument", "-Wno-unused-variable", -- GitLab