Fix python2 bug when creating backup filename

This commit is contained in:
Nick Hall 2014-04-18 22:05:37 +01:00
parent 061a289bde
commit 20c9d949ac

View File

@ -552,12 +552,14 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
def __make_zip_backup(self, dirname): def __make_zip_backup(self, dirname):
import zipfile import zipfile
if sys.version_info[0] < 3:
from string import maketrans
title = self.get_dbname()
# In Windows resrved characters is "<>:"/\|?*" # In Windows resrved characters is "<>:"/\|?*"
reserved_char = r':,<>"/\|?* ' reserved_char = r':,<>"/\|?* '
replace_char = "-__________" replace_char = "-__________"
title = self.get_dbname()
if sys.version_info[0] < 3:
from string import maketrans
trans = maketrans(reserved_char, replace_char)
else:
trans = title.maketrans(reserved_char, replace_char) trans = title.maketrans(reserved_char, replace_char)
title = title.translate(trans) title = title.translate(trans)