diff --git a/dagrt/utils.py b/dagrt/utils.py index b69d107b7953e582bab5f27a0de726cd81fa0e18..e0ddb55666b34ec063a361bde30002164349ccc3 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: @@ -190,9 +188,10 @@ def run_fortran(sources, fortran_options=[]): 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",