code_junkie

Pickled file won't load on Mac/Linux

Nov 12th, 2011
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. unpickle_file = cPickle.load(char_file)
  2.  
  3. def createSaveFile(self):
  4. """Create the data files to be saved and save them.
  5.  
  6. Creates a tuple comprised of a dictionary of general character information
  7. and the character's skills dictionary."""
  8. if self.file_name:
  9. self.save_data = ({'Name':self.charAttribs.name,
  10.  
  11. <snip>
  12.  
  13. self.charAttribs.char_skills_dict)
  14. self.file = open(self.file_name, 'w')
  15. cPickle.dump(self.save_data, self.file)
  16. self.file.close()
  17.  
  18. def getCharFile(self, event): # wxGlade: CharSheet.<event_handler>
  19. """Retrieve pickled character file from disk."""
  20. wildcard = "Character files (*.char) | *.char | All files (*.*) | *.*"
  21. openDialog = wx.FileDialog(None, "Choose a character file", os.getcwd(),
  22. "", wildcard, wx.OPEN | wx.CHANGE_DIR)
  23. if openDialog.ShowModal() == wx.ID_OK:
  24. self.path = openDialog.GetPath()
  25. try:
  26. char_file = open(self.path, "r")
  27. unpickle_file = cPickle.load(char_file)
  28. char_data, char_skills = unpickle_file
  29. self.displayCharacter(char_data, char_skills)
  30. except IOError:
  31. self.importError = wx.MessageDialog(self,
  32. "The character file is not available!",
  33. "Character Import Error", wx.OK | wx.ICON_ERROR)
  34. self.importError.ShowModal()
  35. self.importError.Destroy()
  36. openDialog.Destroy()
  37.  
  38. char_file = open('pickle.char', 'rb')
  39.  
  40. char_file=open('filename.char','rU')
  41.  
  42. char_file = open('filename.char','wb')
  43. cPickle.dumps(data, char_file)
  44.  
  45. self.file = open(self.file_name, 'w')
  46.  
  47. self.file = open(self.file_name, 'wb')
Add Comment
Please, Sign In to add comment