def fromFile(filename):
 with codecs.open(filename, 'rb') as f:
  try:
   contents = cPickle.load(f)
  except TypeError as e:
   f.seek(0)
   name = e.args[1].__name__
   if (name == 'TrialHandler'):
    currentHandler = psychopy.data.TrialHandler
    psychopy.data.TrialHandler = _oldStyleTrialHandler
    oldContents = cPickle.load(f)
    psychopy.data.TrialHandler = currentHandler
    contents = _convertToNewStyle(psychopy.data.TrialHandler, oldContents)
   elif (name == 'StairHandler'):
    currentHandler = psychopy.data.StairHandler
    psychopy.data.StairHandler = _oldStyleStairHandler
    oldContents = cPickle.load(f)
    psychopy.data.StairHandler = currentHandler
    contents = _convertToNewStyle(psychopy.data.StairHandler, oldContents)
   elif (name == 'MultiStairHandler'):
    newStair = psychopy.data.StairHandler
    newMulti = psychopy.data.MultiStairHandler
    psychopy.data.StairHandler = _oldStyleStairHandler
    psychopy.data.MultiStairHandler = _oldStyleMultiStairHandler
    oldContents = cPickle.load(f)
    psychopy.data.MultiStairHandler = newMulti
    psychopy.data.StairHandler = newStair
    contents = _convertToNewStyle(psychopy.data.MultiStairHandler, oldContents)
   else:
    raise TypeError, ("Didn't recognize %s" % name)
 return contents

def fromFile ( filename ) : with codecs . open ( filename , 'rb' ) as f : try : contents = cPickle . load ( f ) except TypeError as e : f . seek ( 0 ) name = e . args [ 1 ] . __name__ if ( name == 'TrialHandler' ) : currentHandler = psychopy . data . TrialHandler psychopy . data . TrialHandler = _oldStyleTrialHandler oldContents = cPickle . load ( f ) psychopy . data . TrialHandler = currentHandler contents = _convertToNewStyle ( psychopy . data . TrialHandler , oldContents ) elif ( name == 'StairHandler' ) : currentHandler = psychopy . data . StairHandler psychopy . data . StairHandler = _oldStyleStairHandler oldContents = cPickle . load ( f ) psychopy . data . StairHandler = currentHandler contents = _convertToNewStyle ( psychopy . data . StairHandler , oldContents ) elif ( name == 'MultiStairHandler' ) : newStair = psychopy . data . StairHandler newMulti = psychopy . data . MultiStairHandler psychopy . data . StairHandler = _oldStyleStairHandler psychopy . data . MultiStairHandler = _oldStyleMultiStairHandler oldContents = cPickle . load ( f ) psychopy . data . MultiStairHandler = newMulti psychopy . data . StairHandler = newStair contents = _convertToNewStyle ( psychopy . data . MultiStairHandler , oldContents ) else : raise TypeError , ( "Didn't recognize %s" % name ) return contents
load data from a pickle file .