From 2c8fe66c0f7490c8aaaae27b4977b987001c6b71 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 01 Dec 2009 20:11:43 +0000 Subject: Merge branch 'master' of git://git.sugarlabs.org/tutorius/simpoirs-clone Conflicts: src/extensions/tutoriusremote.py tutorius/TProbe.py tutorius/creator.py --- (limited to 'tutorius/vault.py') diff --git a/tutorius/vault.py b/tutorius/vault.py index a3b84a4..1c1e33c 100644 --- a/tutorius/vault.py +++ b/tutorius/vault.py @@ -251,26 +251,25 @@ class Vault(object): addition_flag = False # Check if at least one keyword of the list is present for key in keyword: - for value in metadata_dictionnary.values(): - if isinstance(value, str) == True: - if value.lower().count(key.lower()) > 0: - addition_flag = True - else: + if key != None: + for value in metadata_dictionnary.values(): + if isinstance(value, str): + if value.lower().count(key.lower()) > 0: + addition_flag = True # Check one layer of depth in the metadata to find the keyword # (for exemple, related activites are a dictionnary stocked - # in a value of the main dictionnary) - if isinstance(value, dict) == True: + # in a value of the main dictionnary) + elif isinstance(value, dict): for inner_key, inner_value in value.items(): - if isinstance(inner_value, str) == True and isinstance(inner_key, str) == True: - if inner_value.lower().count(key.lower()) > 0 or inner_key.count(key.lower()) > 0: - addition_flag = True + if isinstance(inner_value, str) and isinstance(inner_key, str) and (inner_value.lower().count(key.lower()) > 0 or inner_key.count(key.lower()) > 0): + addition_flag = True # Filter tutorials for related activities if relatedActivityNames != []: addition_flag = False # Check if at least one element of the list is present for related in relatedActivityNames: - if related.lower() in related_act_dictionnary.keys(): + if related != None and related.lower() in related_act_dictionnary.keys(): addition_flag = True # Filter tutorials for categories @@ -278,9 +277,8 @@ class Vault(object): addition_flag = False # Check if at least one element of the list is present for cat in category: - if metadata_dictionnary.has_key(INI_CATEGORY_PROPERTY): - if metadata_dictionnary[INI_CATEGORY_PROPERTY].lower() == cat.lower(): - addition_flag = True + if cat != None and metadata_dictionnary.has_key(INI_CATEGORY_PROPERTY) and metadata_dictionnary[INI_CATEGORY_PROPERTY].lower() == cat.lower(): + addition_flag = True # Add this dictionnary to tutorial list if it has not been filtered if addition_flag == True: @@ -524,6 +522,7 @@ class Vault(object): tutorial_path = bundler.get_tutorial_path(tutorial_guid) # Check if the resource file exists file_path = os.path.join(tutorial_path, RESOURCES_FOLDER, resource_id) + logger.debug("Vault :: Assigning resource %s to file %s "%(resource_id, file_path)) if os.path.isfile(file_path): return file_path else: -- cgit v0.9.1