def fnunpickle(fileorname, number=0, usecPickle=True):
 if (usecPickle and six.PY2):
  import cPickle as pickle
 else:
  import pickle
 if isinstance(fileorname, six.string_types):
  f = open(fileorname, u'rb')
  close = True
 else:
  f = fileorname
  close = False
 try:
  if (number > 0):
   res = []
   for i in range(number):
    res.append(pickle.load(f))
  elif (number < 0):
   res = []
   eof = False
   while (not eof):
    try:
     res.append(pickle.load(f))
    except EOFError:
     eof = True
  else:
   res = pickle.load(f)
 finally:
  if close:
   f.close()
 return res

def fnunpickle ( fileorname , number = 0 , usecPickle = True ) : if ( usecPickle and six . PY2 ) : import cPickle as pickle else : import pickle if isinstance ( fileorname , six . string_types ) : f = open ( fileorname , u'rb' ) close = True else : f = fileorname close = False try : if ( number > 0 ) : res = [ ] for i in range ( number ) : res . append ( pickle . load ( f ) ) elif ( number < 0 ) : res = [ ] eof = False while ( not eof ) : try : res . append ( pickle . load ( f ) ) except EOFError : eof = True else : res = pickle . load ( f ) finally : if close : f . close ( ) return res
unpickle pickled objects from a specified file and return the contents .