Tomas Groth has proposed merging lp:~tomasgroth/openlp/json-service-format into lp:openlp.
Requested reviews: OpenLP Core (openlp-core) For more details, see: https://code.launchpad.net/~tomasgroth/openlp/json-service-format/+merge/168283 2nd merge try... Change the format of the services format from python pickle to json to make eaiser to import/export the files from other system. -- https://code.launchpad.net/~tomasgroth/openlp/json-service-format/+merge/168283 Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/json-service-format into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py' --- openlp/core/ui/servicemanager.py 2013-05-19 07:35:07 +0000 +++ openlp/core/ui/servicemanager.py 2013-06-09 12:29:26 +0000 @@ -35,6 +35,7 @@ import os import shutil import zipfile +import json from tempfile import mkstemp from datetime import datetime, timedelta @@ -458,7 +459,7 @@ path_file_name = unicode(self.file_name()) path, file_name = os.path.split(path_file_name) base_name = os.path.splitext(file_name)[0] - service_file_name = '%s.osd' % base_name + service_file_name = '%s.osjd' % base_name log.debug(u'ServiceManager.save_file - %s', path_file_name) Settings().setValue(self.main_window.service_manager_settings_section + u'/last directory', path) service = [] @@ -512,7 +513,7 @@ 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 = json.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) @@ -572,7 +573,7 @@ path_file_name = unicode(self.file_name()) path, file_name = os.path.split(path_file_name) base_name = os.path.splitext(file_name)[0] - service_file_name = '%s.osd' % base_name + service_file_name = '%s.osjd' % base_name log.debug(u'ServiceManager.save_file - %s', path_file_name) Settings().setValue(self.main_window.service_manager_settings_section + u'/last directory', path) service = [] @@ -698,11 +699,14 @@ log.debug(u'Extract file: %s', osfile) zip_info.filename = osfile zip_file.extract(zip_info, self.servicePath) - if osfile.endswith(u'osd'): + if osfile.endswith(u'osjd') or osfile.endswith(u'osd'): 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) + if osfile.endswith(u'osjd'): + items = json.load(file_to) + else: + items = cPickle.load(file_to) file_to.close() self.new_file() self.set_file_name(file_name)
_______________________________________________ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp