def build_zip(c_path, file_path_output, index_html): c = compress.Compress() css_folder = c_path + "\\css" js_folder = c_path + "\\js" report_folder = c_path + "\\report-details" arrays_files = [report_folder, css_folder, js_folder, index_html] c.build(c_path, arrays_files, file_path_output)
def CompressFiles(dirPath, filename): files = ListDir(dirPath) zipName = "{name}.tar.gz".format(name=filename) comp = compress.Compress(zipName) #comp.Add(dirPath,filename) for file in files.GetNewFiles(): comp.Add(file["path"], file["name"]) comp.Close() return zipName
def DecompressFiles(filename, dirPath): comp = compress.Compress("{name}.tar.gz".format(name=filename)) comp.Extract(dirPath)
import compress import argparse # 添加参数 parser = argparse.ArgumentParser() parser.add_argument('inputFile', help='inputFile') parser.add_argument('outputFile', help='ouputFile') args = parser.parse_args() inputFile = args.inputFile outputFile = args.outputFile mycompress = compress.Compress() mycompress.ziptxt(inputFile, outputFile)