From 4b0a79126af20099588865b69362f4d73d2a93a0 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Fri, 26 Jul 2019 11:05:19 +1200 Subject: [PATCH] refactor whitespace in NAM file and MFList output files --- flopy/discretization/grid.py | 11 +++++------ flopy/mbase.py | 11 +++++++---- flopy/modflow/mf.py | 2 +- flopy/utils/util_list.py | 16 +++++++++------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/flopy/discretization/grid.py b/flopy/discretization/grid.py index 05bad947ce..9ca8bcadb6 100644 --- a/flopy/discretization/grid.py +++ b/flopy/discretization/grid.py @@ -162,12 +162,11 @@ def __init__(self, grid_type=None, top=None, botm=None, idomain=None, # access to basic grid properties ################################### def __repr__(self): - s = "xll:{0:<.10G}; yll:{1:<.10G}; rotation:{2: 0: f_nam.write('{:14s} {:5d} {}\n'.format(self.glo.name[0], diff --git a/flopy/utils/util_list.py b/flopy/utils/util_list.py index ce7dbfd6d3..d79c653b35 100644 --- a/flopy/utils/util_list.py +++ b/flopy/utils/util_list.py @@ -695,13 +695,15 @@ def write_transient(self, f, single_per=None, forceInternal=False): if kper_vtype == np.recarray: name = f.name - f.close() - f = open(name, 'ab+') - # print(f) - self.__tofile(f, kper_data) - f.close() - f = open(name, 'a') - # print(f) + if self.__binary: + f.close() + # switch file append mode to binary + with open(name, 'ab+') as f: + self.__tofile(f, kper_data) + # continue back to non-binary + f = open(name, 'a') + else: + self.__tofile(f, kper_data) elif kper_vtype == str: f.write(' open/close ' + kper_data) if self.__binary: