pickle->cPickle

This commit is contained in:
Marcos Pinto 2007-10-07 20:29:43 +00:00
parent 515305e950
commit 50877923ea
4 changed files with 7 additions and 9 deletions

View File

@ -33,7 +33,7 @@
"""Configuration class used to access/create/modify configuration files.""" """Configuration class used to access/create/modify configuration files."""
import pickle import cPickle
import deluge.common import deluge.common
from deluge.log import LOG as log from deluge.log import LOG as log
@ -71,7 +71,7 @@ class Config:
# Un-pickle the file and update the config dictionary # Un-pickle the file and update the config dictionary
log.debug("Opening pickled file for load..") log.debug("Opening pickled file for load..")
pkl_file = open(filename, "rb") pkl_file = open(filename, "rb")
filedump = pickle.load(pkl_file) filedump = cPickle.load(pkl_file)
self.config.update(filedump) self.config.update(filedump)
pkl_file.close() pkl_file.close()
except IOError: except IOError:
@ -91,7 +91,7 @@ class Config:
try: try:
log.debug("Opening pickled file for comparison..") log.debug("Opening pickled file for comparison..")
pkl_file = open(filename, "rb") pkl_file = open(filename, "rb")
filedump = pickle.load(pkl_file) filedump = cPickle.load(pkl_file)
pkl_file.close() pkl_file.close()
if filedump == self.config: if filedump == self.config:
# The config has not changed so lets just return # The config has not changed so lets just return
@ -103,7 +103,7 @@ class Config:
try: try:
log.debug("Opening pickled file for save..") log.debug("Opening pickled file for save..")
pkl_file = open(filename, "wb") pkl_file = open(filename, "wb")
pickle.dump(self.config, pkl_file) cPickle.dump(self.config, pkl_file)
log.debug("Closing pickled file..") log.debug("Closing pickled file..")
pkl_file.close() pkl_file.close()
except IOError: except IOError:

View File

@ -31,7 +31,6 @@
# this exception statement from your version. If you delete this exception # this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
import pickle
import dbus import dbus
import dbus.service import dbus.service
from dbus.mainloop.glib import DBusGMainLoop from dbus.mainloop.glib import DBusGMainLoop

View File

@ -33,7 +33,7 @@
"""TorrentManager handles Torrent objects""" """TorrentManager handles Torrent objects"""
import pickle import cPickle
import os.path import os.path
import os import os
@ -305,7 +305,7 @@ class TorrentManager:
log.debug("Opening torrent state file for load.") log.debug("Opening torrent state file for load.")
state_file = open(deluge.common.get_config_dir("torrents.state"), state_file = open(deluge.common.get_config_dir("torrents.state"),
"rb") "rb")
state = pickle.load(state_file) state = cPickle.load(state_file)
state_file.close() state_file.close()
except IOError: except IOError:
log.warning("Unable to load state file.") log.warning("Unable to load state file.")
@ -329,7 +329,7 @@ class TorrentManager:
log.debug("Saving torrent state file.") log.debug("Saving torrent state file.")
state_file = open(deluge.common.get_config_dir("torrents.state"), state_file = open(deluge.common.get_config_dir("torrents.state"),
"wb") "wb")
pickle.dump(state, state_file) cPickle.dump(state, state_file)
state_file.close() state_file.close()
except IOError: except IOError:
log.warning("Unable to save state file.") log.warning("Unable to save state file.")

View File

@ -32,7 +32,6 @@
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
import os.path import os.path
import pickle
import dbus import dbus
from dbus.mainloop.glib import DBusGMainLoop from dbus.mainloop.glib import DBusGMainLoop