def new_get_content(self, params, dir_only=None, file_only=None): directory = None br_history = None parser = DataParser() file_chooser = FileChooser() if (params["content_type"] == "image" or params["content_type"] == "audio"): if 'directory' in params: directory = parser.substr(stra=params['directory'], strb=getpass.getuser()) if 'broadcast_history' in params: br_history = parser.substr(stra=params['broadcast_history'], strb=getpass.getuser()) rec_fold = None if 'recursive_folders' in params: rec_fold = params['recursive_folders'] br_hist_ftype = None if 'broadcast_history_ftype' in params: br_hist_ftype = params['broadcast_history_ftype'] # file_loc, dir_only, file_name return file_chooser.get_file(params['selection_alg'], rec_fold, directory, br_history, br_hist_ftype) elif params["content_type"] == "text": data_file = parser.substr(stra=params['data_file'], strb=getpass.getuser()) general_info = file_chooser.get_text( directory=dir_only, selection_alg=params['selection_alg'], data_file=data_file, data_format=params['data_format'], file_name=file_only) text = parser.format_caption(params['format_rules'], general_info) return text
def create_item(self, content_item): parser = Parser() filechooser = FileChooser() textchooser = TextChooser() content_params = content_item.content_item[0] if content_params.content_type == "text": general_info = textchooser.get_text( content_params.selection_alg, content_params.data_file, content_params.data_format, None, None, application=content_item.application) if content_item.application == "poetry": content_item.item_text = parser.format_poem( general_info[0], general_info[1]) else: content_item.item_text = parser.format_caption( content_params.format_rules, general_info) return content_item elif content_params.content_type == "image": image_path = filechooser.get_file(content_params.selection_alg, content_params.recursive_folders, content_params.directory, content_params.history_loc, content_params.history_ftype) content_item.item_image_path = image_path[0] if len(content_item.content_item) > 1: general_info = textchooser.get_text( content_item.content_item[1].selection_alg, content_item.content_item[1].data_file, content_item.content_item[1].data_format, image_path[1], image_path[2]) content_item.item_text = parser.format_caption( content_item.content_item[1].format_rules, general_info) return content_item