From f3bd8e06e2cd0acebad6dbd77ff32ff3de1c2860 Mon Sep 17 00:00:00 2001 From: JCTutorius Date: Mon, 23 Nov 2009 19:31:27 +0000 Subject: Made change after Charlie code review. --- (limited to 'tutorius') diff --git a/tutorius/vault.py b/tutorius/vault.py index a3b84a4..8d680b1 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: -- cgit v0.9.1