File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44ZIP_PASS = DEF .ZIP_PASS
55
66import os
7+ import zipfile
78class Ziputil ():
89 def __init__ (self , ziptoolpath :str , zipfilepath :str ):
910 self .ziptoolpath = ziptoolpath
1011 self .zipfilepath = zipfilepath
1112 self .password = ZIP_PASS
13+ self .using7z = True
14+ if len (self .ziptoolpath )== 0 :
15+ self .using7z = False
1216 def getzipfile (self ):
13- with open ('blankfile' ,'w' ) as f :
14- f .write ('\n ' )
15- command = ' a ' + self .zipfilepath + ' ' + os .getcwd ()+ '\\ blankfile -p' + ZIP_PASS
16- print (self .ziptoolpath + command )
17- code = os .system (self .ziptoolpath + command )
18- return code
17+ if self .using7z :
18+ with open ('blankfile' ,'w' ) as f :
19+ f .write ('\n ' )
20+ command = ' a ' + self .zipfilepath + ' ' + os .getcwd ()+ '\\ blankfile -p' + ZIP_PASS
21+ print (self .ziptoolpath + command )
22+ code = os .system (self .ziptoolpath + command )
23+ return code
1924 def genzipfile (self ,folder_path :str ):
20- command = " a -t7z -scsUTF-8 " + self .zipfilepath + " " + folder_path + "\\ * -p" + ZIP_PASS
21- print (self .ziptoolpath + command )
22- code = os .system (self .ziptoolpath + command )
23- return code
25+ if self .using7z :
26+ command = " a -t7z -scsUTF-8 " + self .zipfilepath + " " + folder_path + "\\ * -p" + ZIP_PASS
27+ print (self .ziptoolpath + command )
28+ code = os .system (self .ziptoolpath + command )
29+ return code
2430
2531
2632def load_serval (str_serval :str ): #load a serval file
You can’t perform that action at this time.
0 commit comments