I wrote a script in Python to clean archives of jar (I know classes which I need with Class Dependency Analyzer) This is my script :
def deleteJarEntrie(pJarPath) :
# Dictionary contains className of jar file for key
# and a list of class for value
for key in myDict.keys():
zin = zipfile.ZipFile (pJarPath+key, 'r')
zout = zipfile.ZipFile (key, 'w')
# for each entry in zip file
for item in zin.infolist():
# if the className of the file finished by one “/” it is a directory
# thus I do not reiterate values of the dictionary
if (item.filename[-1:] != "/"):
# For each value of my dictionary (the value are the classes which I need)
for value in myDict.get(key):
buffer = zin.read(item.filename)
className = item.filename.split("/")
className = className[len(className)-1]
if (item.filename == value):
zout.writestr(item, buffer)
print item.filename
zout.close()
zin.close()'
The problem is that item.filename never take class-file name for value, item.filename only take value of directory, but it can take value of MANIFEST.MF.
For example :
I've a class in /org/test/myClass.class
-> item.filename = /org/test/
I've a manifest in /META-INF/MANIFEST.MF
-> item.filename = /META-INF/MANIFEST.MF
I don't understant why I can't see class-file...
Thank you for your answers and sorry if my english is not correct.