Class Unrarmodel: def __init__ (self, filepath): Self.rar = Rarfile. Rarfile (filepath) self.infolist = Self.rar.infolist () def extral_list (self, selected_dir): selected_ Infolist = [] for D in Selected_dir: for info in self.infolist: filename = info.filename.replace ("\ \", "/")
# in Win if Filename.find (d)! =-1 and Info.file_size! = 0L: selected_infolist.append (info) return Selected_infolist def decompression_list (self, Selected_infolist, To_dir): "" " Extract the Specified Directory :p Aram selected_infolist:specified directory :p Aram to_dir:destination : return: "" " Self.rar.extractall (Path=to_dir, Members=selected_infolist)
def rar_decompression (From_path, To_path): From_path = from_path.replace ("\ \", "/") # in win rar = rarfile. Rarfile (From_path) Rar.extractall (To_path) standout_print ("Info:decompression%s to%s finish."% (From_path , To_path)) def remove_file (File_path): "" " Remove file :p Aram File_path: : return: " "" Os.remove (File_path) standout_print ("Info:remove files%s finish."% File_path)
Python Unrar uncompressed