tools/lspisi dirs xxx.pisi klasör listesini, tools/lspisi xxx.pisi içeriği versin...
This commit is contained in:
+29
-11
@@ -9,31 +9,49 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
if not sys.argv[1]:
|
def openZip(fileName):
|
||||||
print "pisi file name required..."
|
if not zipfile.is_zipfile(fileName):
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
if not zipfile.is_zipfile(sys.argv[1]):
|
|
||||||
print "ZIP file required..."
|
print "ZIP file required..."
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
else:
|
||||||
|
f = zipfile.ZipFile(fileName, "r")
|
||||||
|
return f
|
||||||
|
|
||||||
f = zipfile.ZipFile(sys.argv[1], "r")
|
def fillFileList(zipFile):
|
||||||
|
|
||||||
filelist = []
|
filelist = []
|
||||||
|
|
||||||
for file in f.namelist():
|
for file in zipFile.namelist():
|
||||||
filelist.append(file)
|
filelist.append(file)
|
||||||
|
|
||||||
filelist.sort()
|
filelist.sort()
|
||||||
|
return filelist
|
||||||
|
|
||||||
for file in filelist:
|
def uniq(alist):
|
||||||
|
set = {}
|
||||||
|
return [set.setdefault(e,e) for e in alist if e not in set]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if sys.argv[1] == "dirs":
|
||||||
|
f = openZip(sys.argv[2])
|
||||||
|
dirlist =[]
|
||||||
|
for file in fillFileList(f):
|
||||||
|
dirlist.append(os.path.dirname(file))
|
||||||
|
|
||||||
|
for dir in uniq(dirlist):
|
||||||
|
print dir
|
||||||
|
elif sys.argv[1]:
|
||||||
|
f = openZip(sys.argv[1])
|
||||||
|
for file in fillFileList(f):
|
||||||
if f.getinfo(file).external_attr == 2716663808:
|
if f.getinfo(file).external_attr == 2716663808:
|
||||||
print file + " --> symlink"
|
print file + " --> symlink"
|
||||||
else:
|
else:
|
||||||
print file
|
print file
|
||||||
|
else:
|
||||||
|
print "pisi file name required..."
|
||||||
|
sys.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user