diff options
author | JCTutorius <charlie@tutorius-dev.(none)> | 2009-11-06 02:21:08 (GMT) |
---|---|---|
committer | JCTutorius <charlie@tutorius-dev.(none)> | 2009-11-06 02:21:08 (GMT) |
commit | 7aad5a2f6a93ae3385794f94f8b175c243165532 (patch) | |
tree | 0ea47c2adbfee2780fac2675e2ca860dc1a39b15 /tutorius | |
parent | 29aea8f7d71d5584e011a6955999e37efe6343f9 (diff) |
Made change after Charlie code review.
Diffstat (limited to 'tutorius')
-rw-r--r-- | tutorius/vault.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tutorius/vault.py b/tutorius/vault.py index c0409da..fbe9e75 100644 --- a/tutorius/vault.py +++ b/tutorius/vault.py @@ -367,8 +367,8 @@ class Vault(object): parser.set(INI_ACTIVITY_SECTION, related_key, related_value) # Delete the old metadata file - if os.path.isfile(ini_file_path): - os.remove(ini_file_path) +## if os.path.isfile(ini_file_path): +## os.remove(ini_file_path) # Write the new metadata file to disk with open(ini_file_path, 'wb') as configfile: @@ -391,15 +391,24 @@ class Vault(object): bundle_path = bundle.get_tutorial_path(guid) #Zip the tutorials files in the pkzip file format in a temp file - archive_list = [os.path.join(bundle_path, 'meta.ini'), os.path.join(bundle_path, 'tutorial.xml')] #, os.path.join(bundle_path, RESOURCES_FOLDER)] + archive_list = [os.path.join(bundle_path, 'meta.ini'), os.path.join(bundle_path, 'tutorial.xml')] + + # Add all the files in the archive folder + for root, dirs, files in os.walk(os.path.join(bundle_path, RESOURCES_FOLDER)): + for name in files: + archive_list.append(os.path.join(bundle_path, RESOURCES_FOLDER, name)) zfilename = str(guid) + ".zip" zout = zipfile.ZipFile(os.path.join(bundle_path, zfilename), "w") for fname in archive_list: fname_splitted = fname.rsplit('/') - file_only_name = fname_splitted[fname_splitted.__len__() - 1] - zout.write(fname, file_only_name) + if fname_splitted[-2] == RESOURCES_FOLDER: + ressource_path_and_file = os.path.join(fname_splitted[-2], fname_splitted[-1]) + zout.write(fname, ressource_path_and_file) + else: + file_only_name = fname_splitted[-1] + zout.write(fname, file_only_name) zout.close() # test if the temp file is a valid pkzip file |