forked from openlp/openlp
replaced cPickle by pickle
This commit is contained in:
parent
4b76db7ad7
commit
72ba94d390
@ -29,7 +29,7 @@
|
||||
"""
|
||||
Provide HTML Tag management and Formatting Tag access class
|
||||
"""
|
||||
import cPickle
|
||||
import pickle
|
||||
|
||||
from openlp.core.lib import Settings, translate
|
||||
|
||||
@ -66,7 +66,7 @@ class FormattingTags(object):
|
||||
if isinstance(tag[element], unicode):
|
||||
tag[element] = tag[element].encode('utf8')
|
||||
# Formatting Tags were also known as display tags.
|
||||
Settings().setValue(u'displayTags/html_tags', cPickle.dumps(tags) if tags else u'')
|
||||
Settings().setValue(u'displayTags/html_tags', pickle.dumps(tags) if tags else u'')
|
||||
|
||||
@staticmethod
|
||||
def load_tags():
|
||||
@ -159,10 +159,8 @@ class FormattingTags(object):
|
||||
|
||||
# Formatting Tags were also known as display tags.
|
||||
user_expands = Settings().value(u'displayTags/html_tags')
|
||||
# cPickle only accepts str not unicode strings
|
||||
user_expands_string = str(user_expands)
|
||||
if user_expands_string:
|
||||
user_tags = cPickle.loads(user_expands_string)
|
||||
user_tags = pickle.loads(user_expands_string)
|
||||
for tag in user_tags:
|
||||
for element in tag:
|
||||
if isinstance(tag[element], str):
|
||||
|
@ -30,7 +30,7 @@
|
||||
The service manager sets up, loads, saves and manages services.
|
||||
"""
|
||||
import cgi
|
||||
import cPickle
|
||||
import pickle
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
@ -507,7 +507,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
file_size = os.path.getsize(file_item)
|
||||
total_size += file_size
|
||||
log.debug(u'ServiceManager.save_file - ZIP contents size is %i bytes' % total_size)
|
||||
service_content = cPickle.dumps(service)
|
||||
service_content = pickle.dumps(service)
|
||||
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be extracted using unzip in UNIX.
|
||||
allow_zip_64 = (total_size > 2147483648 + len(service_content))
|
||||
log.debug(u'ServiceManager.save_file - allowZip64 is %s' % allow_zip_64)
|
||||
@ -580,7 +580,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
#TODO: check for file item on save.
|
||||
service.append({u'serviceitem': service_item})
|
||||
self.main_window.increment_progress_bar()
|
||||
service_content = cPickle.dumps(service)
|
||||
service_content = pickle.dumps(service)
|
||||
zip_file = None
|
||||
success = True
|
||||
self.main_window.increment_progress_bar()
|
||||
@ -697,7 +697,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
|
||||
p_file = os.path.join(self.servicePath, osfile)
|
||||
if 'p_file' in locals():
|
||||
file_to = open(p_file, u'r')
|
||||
items = cPickle.load(file_to)
|
||||
items = pickle.load(file_to)
|
||||
file_to.close()
|
||||
self.new_file()
|
||||
self.set_file_name(file_name)
|
||||
|
@ -33,11 +33,11 @@ class TestFormattingTags(TestCase):
|
||||
"""
|
||||
with patch(u'openlp.core.lib.translate') as mocked_translate, \
|
||||
patch(u'openlp.core.lib.settings') as mocked_settings, \
|
||||
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
|
||||
patch(u'openlp.core.lib.formattingtags.pickle') as mocked_pickle:
|
||||
# GIVEN: Our mocked modules and functions.
|
||||
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
|
||||
mocked_settings.value.return_value = u''
|
||||
mocked_cPickle.load.return_value = []
|
||||
mocked_pickle.load.return_value = []
|
||||
|
||||
# WHEN: Get the display tags.
|
||||
FormattingTags.load_tags()
|
||||
@ -54,11 +54,11 @@ class TestFormattingTags(TestCase):
|
||||
"""
|
||||
with patch(u'openlp.core.lib.translate') as mocked_translate, \
|
||||
patch(u'openlp.core.lib.settings') as mocked_settings, \
|
||||
patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle:
|
||||
patch(u'openlp.core.lib.formattingtags.pickle') as mocked_pickle:
|
||||
# GIVEN: Our mocked modules and functions.
|
||||
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
|
||||
mocked_settings.value.return_value = u''
|
||||
mocked_cPickle.loads.side_effect = [[], [TAG]]
|
||||
mocked_pickle.loads.side_effect = [[], [TAG]]
|
||||
|
||||
# WHEN: Get the display tags.
|
||||
FormattingTags.load_tags()
|
||||
|
@ -2,7 +2,7 @@
|
||||
Package to test the openlp.core.lib package.
|
||||
"""
|
||||
import os
|
||||
import cPickle
|
||||
import pickle
|
||||
from unittest import TestCase
|
||||
from mock import MagicMock, patch
|
||||
|
||||
@ -272,7 +272,7 @@ class TestServiceItem(TestCase):
|
||||
service_file = os.path.join(TEST_PATH, name)
|
||||
try:
|
||||
open_file = open(service_file, u'r')
|
||||
items = cPickle.load(open_file)
|
||||
items = pickle.load(open_file)
|
||||
first_line = items[0]
|
||||
except IOError:
|
||||
first_line = u''
|
||||
|
Loading…
Reference in New Issue
Block a user