def analyse_from_file(path): """Analyses messages from a single file which was previously created by this program. Notes: Requires all the necessary configuration parameters (config.ini file) to be set either by GUI or manually. """ _, _, words_file, your_name, target_name = storage.get_session_params() msgs = storage.get_msgs(path) asyncio.get_event_loop().run_until_complete( _analyse(msgs, your_name, target_name, words_file, store_msgs=False))
async def retrieve_and_analyse(loop): """(async) Analyses messages from VkOpt file and/or Telegram dialogue. Notes: Requires all the necessary configuration parameters (config.ini file) to be set either by GUI or manually. """ dialog, vkopt_file, words_file, your_name, target_name = storage.get_session_params( ) msgs = await _get_all_messages(dialog, vkopt_file, your_name, target_name, loop) await _analyse(msgs, your_name, target_name, words_file)
def raise_files_frame(self): """Chooses a file with words and a file with VkOpt messages; assigns names.""" table_frame = tk.Frame() table_frame.pack(expand=True, fill="both") cur_row = 0 if self.session_params["from_vk"]: cur_row += 1 vkopt_label = tk.Label(table_frame, text="Choose path to:", height=2, font=self.default_font) vkopt_label.grid(row=cur_row, column=1, sticky=tk.W) vkopt_button = tk.Button( table_frame, text="vkOpt file", command=lambda: self.__set_file_path(vkopt_filename_label_text, "vkopt_file"), font=self.default_font) vkopt_button.grid(row=cur_row, column=2, sticky=tk.W) cur_row += 1 vkopt_filename_label_text = tk.StringVar() vkopt_filename_label_text.set("File : ") vkopt_filename_label = tk.Label( table_frame, textvariable=vkopt_filename_label_text, height=2, font=self.default_font) vkopt_filename_label.grid(row=cur_row, column=1, sticky=tk.W, columnspan=30) if self.session_params["plot_words"]: cur_row += 1 words_label = tk.Label(table_frame, text="Choose path to:", height=2, font=self.default_font) words_label.grid(row=cur_row, column=1, sticky=tk.W) words_button = tk.Button( table_frame, text="words file", command=lambda: self.__set_file_path(words_filename_label_text, "words_file"), font=self.default_font) words_button.grid(row=cur_row, column=2, sticky=tk.W) cur_row += 1 words_filename_label_text = tk.StringVar() words_filename_label_text.set("File : ") words_filename_label = tk.Label( table_frame, textvariable=words_filename_label_text, height=2, font=self.default_font) words_filename_label.grid(row=cur_row, column=1, sticky=tk.W, columnspan=30) _, _, _, your_name, target_name = storage.get_session_params() cur_row += 1 your_name_label = tk.Label(table_frame, text="Your name: ", height=2, font=self.default_font) your_name_label.grid(row=cur_row, column=1, sticky=tk.W) your_name_dir = tk.Entry(table_frame, width=40, font=self.default_font) your_name_dir.insert(tk.END, your_name) your_name_dir.grid(row=cur_row, column=2) cur_row += 1 target_name_label = tk.Label(table_frame, text="Target's name: ", height=2, font=self.default_font) target_name_label.grid(row=cur_row, column=1, sticky=tk.W) target_name_dir = tk.Entry(table_frame, width=40, font=self.default_font) target_name_dir.insert(tk.END, target_name) target_name_dir.grid(row=cur_row, column=2) if self.session_params["from_vk"]: cur_row += 1 names_label = tk.Label( table_frame, text= ("Please be sure these names are equal to the names in the \n" "vkOpt file. Otherwise vkOpt file will not be read correctly." ), fg="red", height=2, font=self.default_font, justify="left") names_label.grid(row=cur_row, column=1, sticky=tk.W, columnspan=30) def set_data_and_continue(): your_name_label.config(fg="black") target_name_label.config(fg="black") if your_name_dir.get().isspace() or not your_name_dir.get(): return your_name_label.config(fg="red") if target_name_dir.get().isspace() or not target_name_dir.get(): return target_name_label.config(fg="red") if self.session_params["from_vk"]: if "vkopt_file" not in self.session_params: return vkopt_filename_label.config(fg="red") vkopt_filename_label.config(fg="black") if self.session_params["plot_words"]: if "words_file" not in self.session_params: return words_filename_label.config(fg="red") words_filename_label.config(fg="black") self.session_params["your_name"] = your_name_dir.get() self.session_params["target_name"] = target_name_dir.get() bottom_frame.destroy() table_frame.destroy() if self.session_params["from_telegram"]: return self.raise_telegram_auth_frame() self.raise_finish_frame() bottom_frame = tk.Frame() bottom_frame.pack(side=tk.BOTTOM) continue_button = tk.Button(bottom_frame, text="Continue", command=set_data_and_continue, padx=35, background=self.button_background, font=self.default_font) continue_button.pack(side=tk.BOTTOM) self.parent.bind('<Return>', lambda _: set_data_and_continue())