class ResultController: def __init__(self): self.common_tools = Common() self.search_type = self.common_tools.enum(SubDirectory=1, FileName=2, FileContent=3) @staticmethod def convert_item_to_result_object(item, current_root_directory, current_search_type, item_content=None): result_dictionary = {} result_dictionary["size"] = getsize(join(current_root_directory, item)) result_dictionary["is_directory"] = os.path.isdir(os.path.join(os.path.expanduser(current_root_directory), item)) result_dictionary["root_directory"] = str(current_root_directory) result_dictionary["name"] = str(item) result_dictionary["search_type"] = current_search_type if not item_content is None: result_dictionary["item_content"] = item_content return result_dictionary def convert_list_to_result_object_dictionary(self, current_list, last_dict_enumerator, current_root_directory, current_search_type): dictionary_enumerator = last_dict_enumerator new_dictionary = {} for item in current_list: assert isinstance(item, str) dictionary_enumerator += 1 new_dictionary[dictionary_enumerator] = self.convert_item_to_result_object(item, current_root_directory, current_search_type) return new_dictionary
class NotificationController: def __init__(self): self.common_tools = Common() self.notification_category = self.common_tools.enum(Normal=Style.NORMAL + Fore.CYAN, Large_Header=Style.BRIGHT + Back.RED + Fore.WHITE, Header=Style.BRIGHT + Back.WHITE + Fore.BLACK, Small_Header=Style.NORMAL + Fore.MAGENTA, Small_Print=Style.NORMAL + Fore.GREEN, Warning=Style.BRIGHT + Fore.YELLOW, Error=Style.BRIGHT + Fore.RED, Style=Style.NORMAL + Fore.BLUE) def print_with_style(self, output, notification_category): # Initialize colorama object init() if not notification_category: notification_category = self.notification_category.Normal print notification_category + output + Style.RESET_ALL