MCPcopy
hub / github.com/blackboxo/CleanMyWechat / open_file

Method open_file

main.py:509–534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

507 self.setWarninginfo("没有找到当前账号的文件夹路径。")
508
509 def open_file(self):
510 openfile_path = QFileDialog.getExistingDirectory(self, '选择微信数据目录', '')
511 if not openfile_path or openfile_path == '':
512 return False
513 if check_dir(openfile_path) == 0:
514 self.setSuccessinfo('读取路径成功!')
515 dir_list, user_list = get_dir_name(openfile_path)
516 # 如果已有用户配置,那么写入新的用户配置,否则默认写入新配置
517 user_config = []
518 existing_user_config_dic = existing_user_config()
519 for index, user_wx_id in enumerate(user_list):
520 user_dir = dir_list[index]
521 if user_wx_id in existing_user_config_dic:
522 uc = existing_user_config_dic[user_wx_id]
523 uc["data_dir"] = user_dir
524 uc["client_type"] = detect_client_type(user_dir)
525 user_config.append(uc)
526 else:
527 user_config.append(make_default_user_config(user_wx_id, user_dir))
528
529 config = ensure_config_defaults({"data_dir": dir_list, "users": user_config})
530
531 save_json(CONFIG_PATH, config)
532 self.load_config()
533 else:
534 self.setWarninginfo('请选择正确的文件夹!\n微信一般选 WeChat Files,企业微信一般选 WXWork。')
535
536 def save_config(self):
537 self.update_config()

Callers

nothing calls this directly

Calls 10

load_configMethod · 0.95
check_dirFunction · 0.90
get_dir_nameFunction · 0.90
existing_user_configFunction · 0.90
detect_client_typeFunction · 0.85
make_default_user_configFunction · 0.85
ensure_config_defaultsFunction · 0.85
save_jsonFunction · 0.85
setSuccessinfoMethod · 0.80
setWarninginfoMethod · 0.80

Tested by

no test coverage detected