How to write Wechat cleaning tool based on Python
= day: file_list.append (file_path) def getPathFileNum (self, now, day, path_one, path_two, file_list, dir_list): # caculate path_one self.pathFileDeal (now, day, path_one, file_list Dir_list) td = datetime.datetime.now ()-datetime.timedelta (days=day) td_year = td.year td_month = td.month # caculate path_two if os.path.exists (path_two): osdir = os.listdir (path_two) dirlist = [] for i in range (0 Len (osdir): file_path = os.path.join (path_two, osdir [I]) if os.path.isdir (file_path): dirlist.append (osdirt [I]) for i in range (0, len (dirlist)): file_path = os.path.join (path_two) Dirlist [I]) if os.path.isfile (file_path): continue if re.match ('\ d {4} (\ -)\ d {2}', dirlist [I])! = None: cyear = int (dirlist [I] .split ('-', 1) [0]) cmonth = int (dirlist [I] .split ('-') 1) [1]) if self.__before_deadline (cyear, cmonth, td_year Td_month): dir_list.append (file_path) else: if cmonth = = td_month: self.pathFileDeal (now, day, file_path, file_list Dir_list) def _ _ before_deadline (self, cyear, cmonth, td_year, td_month): if cyear
< td_year: return True elif cyear >Td_year: return False elif cyear = = td_year: return cmonth < td_month def callback (self, v): value = v / int ((self.total_file + self.total_dir)) * 100self.bar_progress.setValue (value) if value = = 100: out = "this total clean file" + str (self.total_file) + " Folder "+ str (self.total_dir) +". Please go to the Recycle Bin to check and empty it. " Self.setSuccessinfo (out) return def justdoit (self): # the design of this Api is so stupid, in fact, dir can be put directly in user. Change fd = open (working_dir + "/ config.json") when you have time. Encoding= "utf-8") self.config = json.load (fd) I = 0 need_clean = False thread_list = [] total_file = 0 total_dir = 0 share_thread_arr = [0] for value in self.config ["users"]: file_list = [] dir_list = [] If value ["is_clean"]: self.get_fileNum (self.config ["data_dir"] [I] Int (value ["clean_days"]), value ["clean_pic_cache"], value ["clean_file"], value ["clean_pic"], value ["clean_video"], file_list Dir_list) if len (file_list) + len (dir_list)! = 0: need_clean = True total_file + = len (file_list) total_dir + = len (dir_list) thread_list.append (multiDeleteThread (file_list, dir_list) Share_thread_arr) thread_list [- 1] .delete _ process_signal.connect (self.callback) I = I + 1 if not need_clean: self.setWarninginfo ("no files to clean") else: self.total_file = total_file self.total_dir = total_dir for thread in Thread_list: thread.run () def _ _ init__ (self): super (). _ _ init__ () loadUi (working_dir + "/ images/main.ui" Self) self._frame () self._eventfilter () self.doFadeIn () self.config_exists = True # determine whether the configuration file exists if not os.path.exists (working_dir + "/ config.json"): self.setWarninginfo ("the configuration file does not exist! Please click "Settings" to create a configuration file) self.config_exists = False self.show () if _ _ name__ = ='_ _ main__': app = QApplication ([]) win = MainWindow () app.exec_ () the above is about "how to write Wechat cleaning tool based on Python". I believe you all have some understanding. I hope the content shared by the editor will be helpful to all of you. If you want to know more about the relevant knowledge, please follow the industry information channel.