forked from openlp/openlp
theme import fixes
This commit is contained in:
parent
07039a4908
commit
3db606f653
@ -514,23 +514,17 @@ class ThemeManager(QtGui.QWidget):
|
||||
else:
|
||||
abort_import = False
|
||||
for name in theme_zip.namelist():
|
||||
try:
|
||||
uname = unicode(name, u'utf-8')
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Theme file contains non utf-8 filename "%s"' %
|
||||
name.decode(u'utf-8', u'replace'))
|
||||
raise Exception(u'validation')
|
||||
uname = uname.replace(u'/', os.path.sep)
|
||||
split_name = uname.split(os.path.sep)
|
||||
name = name.replace(u'/', os.path.sep)
|
||||
split_name = name.split(os.path.sep)
|
||||
if split_name[-1] == u'' or len(split_name) == 1:
|
||||
# is directory or preview file
|
||||
continue
|
||||
full_name = os.path.join(directory, uname)
|
||||
full_name = os.path.join(directory, name)
|
||||
check_directory_exists(os.path.dirname(full_name))
|
||||
if os.path.splitext(uname)[1].lower() == u'.xml':
|
||||
if os.path.splitext(name)[1].lower() == u'.xml':
|
||||
file_xml = unicode(theme_zip.read(name), u'utf-8')
|
||||
out_file = open(full_name, u'w')
|
||||
out_file.write(file_xml.encode(u'utf-8'))
|
||||
out_file.write(file_xml)
|
||||
else:
|
||||
out_file = open(full_name, u'wb')
|
||||
out_file.write(theme_zip.read(name))
|
||||
|
Loading…
Reference in New Issue
Block a user