nexus: support loading pickle files created with Python 2

This commit is contained in:
Jaron Krogel 2020-01-31 14:32:57 -05:00
parent 7ec4b00cc1
commit e0d2b6dbbc
2 changed files with 15 additions and 2 deletions

View File

@ -30,6 +30,16 @@ if help:
#end if
paths = dict()
if len(paths_in)==1 and os.path.exists(paths_in[0]) and os.path.isfile(paths_in[0]):
text = open(paths_in[0],'r').read()
paths_in = []
for line in text.splitlines():
tokens = line.split()
if len(tokens)>0:
paths_in.append(tokens[-1])
#end if
#end for
#end if
for path in paths_in:
if os.path.exists(path) and os.path.isdir(path):
simdir = False

View File

@ -359,7 +359,11 @@ class object_interface(object):
fpath='./'+self.__class__.__name__+'.p'
#end if
fobj = open(fpath,'rb')
try:
tmp = pickle.load(fobj)
except:
tmp = pickle.load(fobj,encoding='latin1')
#end try
fobj.close()
d = self.__dict__
d.clear()
@ -372,7 +376,6 @@ class object_interface(object):
#end def load
# log, warning, and error messages
def open_log(self,filepath):
self._logfile = open(filepath,'w')