Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidejouer/tools/storage.py
diff options
context:
space:
mode:
Diffstat (limited to 'atoidejouer/tools/storage.py')
-rw-r--r--atoidejouer/tools/storage.py47
1 files changed, 20 insertions, 27 deletions
diff --git a/atoidejouer/tools/storage.py b/atoidejouer/tools/storage.py
index 829e6f5..f18e892 100644
--- a/atoidejouer/tools/storage.py
+++ b/atoidejouer/tools/storage.py
@@ -477,7 +477,7 @@ def import_project(activity_, file_path, msg_label):
except Exception, e:
# prepare message
_msg = _('Project import failed!')
- _msg = _('%s\n\n[Error] Can not read archive file!' % _msg)
+ _msg += _('\n\n[Error] Can not read archive file!')
# remove tmp structure
__remove_dir('tmp', parent=None)
# quit!
@@ -495,7 +495,7 @@ def import_project(activity_, file_path, msg_label):
else:
# prepare message
_msg = _('Project import failed!')
- _msg = _('%s\n\n[Error] Can not load files!' % _msg)
+ _msg += _('\n\n[Error] Can not load files!')
# remove tmp structure
__remove_dir('tmp', parent=None)
# quit!
@@ -505,8 +505,7 @@ def import_project(activity_, file_path, msg_label):
pass
else:
# prepare message
- _msg = _('%s\n\n[Warning] Following files already exist:\n'\
- % _msg)
+ _msg += _('\n\n[Warning] Following files already exist:\n')
for _f in _exist_list:
_msg = '%s - %s\n' % (_msg, _f)
# merge keys
@@ -514,7 +513,7 @@ def import_project(activity_, file_path, msg_label):
if _existing_dict is None:
# prepare message
_msg = _('Project import failed!')
- _msg = _('%s\n\n[Error] Can not load keys!' % _msg)
+ _msg += _('\n\n[Error] Can not load keys!')
# remove tmp structure
__remove_dir('tmp', parent=None)
# quit!
@@ -524,8 +523,7 @@ def import_project(activity_, file_path, msg_label):
pass
else:
# prepare message
- _msg = _('%s\n\n[Warning] Following sequences already exist:\n'
- % _msg)
+ _msg += _('\n\n[Warning] Following sequences already exist:\n')
for _s in _existing_dict['graphics']:
_msg = '%s - graphics.%s\n' % (_msg, _s)
_msg = '%s\n' % _msg
@@ -563,15 +561,6 @@ def __remove_dir(dir_name, parent=None):
pass
-def __get_sequence_names(sequence_path):
- _f = open(sequence_path)
- _names = _f.readlines()
- _f.close()
- # ..
- for _n in _names:
- yield _n.strip()
-
-
def __export_seq_and_res(activity_, tmp_root, type_='graphics'):
# path updates
_seq_src = os.path.join(activity.get_activity_root(), 'data', 'sequences',
@@ -587,11 +576,14 @@ def __export_seq_and_res(activity_, tmp_root, type_='graphics'):
_ext = '.png' if type_ == 'graphics' else '.ogg'
# copy
for _n in _keys._names:
- _s_path = os.path.join(_seq_src, '%s.seq' % _n)
- shutil.copy(_s_path, _seq_dst)
- for _res in __get_sequence_names(_s_path):
- _res_path = os.path.join(_res_root, '%s%s' % (_res, _ext))
- shutil.copy(_res_path, _res_dst)
+ if _n.strip() == '':
+ continue
+ else:
+ _s_path = os.path.join(_seq_src, '%s.seq' % _n)
+ shutil.copy(_s_path, _seq_dst)
+ for _res in get_sequence_items(_s_path):
+ _res_path = os.path.join(_res_root, '%s%s' % (_res, _ext))
+ shutil.copy(_res_path, _res_dst)
def export_project(activity_, msg_label, media):
@@ -630,22 +622,23 @@ def export_project(activity_, msg_label, media):
try:
if os.path.exists(os.path.join('/media', media, _tar_name)):
# ..
- _msg = _('Project "%(name)s" already exported to "%(media)s"!'\
- % {"name": _name, "media": media})
+ _msg = _('Project') + ' "' + _name + '" '
+ _msg += _('already exported to') + ' "' + media + '" '
else:
# ..
shutil.copy(os.path.join(_tmp_root, _tar_name),
os.path.join('/media', media))
# ..
- _msg = _('Project "%(name)s" sucessfully exported to "%(media)s"'\
- % {"name": _name, "media": media})
+ _msg = _('Project') + ' "' + _name + '" '
+ _msg += _('sucessfully exported to') + ' "' + media + '" '
except Exception, e:
# ERROR
logger.error('[storage] export_project - e: %s' % e)
# ERROR
# ..
- _msg = _('Project "%(name)s" export to "%(media)s" failed!'\
- % {"name": _name, "media": media})
+ # ..
+ _msg = _('Project') + ' "' + _name + '" '
+ _msg += _('export to') + ' "' + media + '" ' + _('failed!')
# remove tmp structure
__remove_dir('tmp', parent=None)
# tmp message