From 0c04022efee82dd6af4b4e965bc6d8cf2ca945aa Mon Sep 17 00:00:00 2001 From: dave <dave@dtu.dk> Date: Wed, 2 Mar 2016 11:04:58 +0100 Subject: [PATCH] wetb.dlcdefs: fix PY2/3 compatibility issue --- wetb/prepost/dlcdefs.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/wetb/prepost/dlcdefs.py b/wetb/prepost/dlcdefs.py index 822b20e5..687cc4ee 100644 --- a/wetb/prepost/dlcdefs.py +++ b/wetb/prepost/dlcdefs.py @@ -9,6 +9,7 @@ from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import from builtins import str +from future.utils import viewitems from future import standard_library standard_library.install_aliases() @@ -284,7 +285,7 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0, opt_tags = [] - for dlc, df in df_list.items(): + for (dlc, df) in viewitems(df_list): # replace ';' with False, and Nan(='') with True # this is more easy when testing for the presence of stuff compared # to checking if a value is either True/False or ''/';' @@ -298,19 +299,19 @@ def excel_stabcon(proot, fext='xlsx', pignore=None, sheet=0, for count, row in df2.iterrows(): tags_dict = {} # construct to dict, convert unicode keys/values to strings - for key, value in row.items(): + for key, value in row.iteritems(): if isinstance(value, str): tags_dict[str(key)] = str(value) else: tags_dict[str(key)] = value # convert ; and empty to False/True -# if isinstance(tags_dict[str(key)], str): - if tags_dict[str(key)] == ';': - tags_dict[str(key)] = False - elif tags_dict[str(key)] == '': - tags_dict[str(key)] = True - elif tags_dict[str(key)].lower() == 'nan': - tags_dict[str(key)] = True + if isinstance(tags_dict[str(key)], str): + if tags_dict[str(key)] == ';': + tags_dict[str(key)] = False + elif tags_dict[str(key)] == '': + tags_dict[str(key)] = True + elif tags_dict[str(key)].lower() == 'nan': + tags_dict[str(key)] = True tags_dict['[Case folder]'] = tags_dict['[Case folder]'].lower() tags_dict['[Case id.]'] = tags_dict['[Case id.]'].lower() -- GitLab