I need to open an manifest.v3 file and read the version field (xml file), and to do that I’m using the following code:
from zipfile import ZipFile
zf = ZipFile("somezip.zip")
for name in zf.namelist():
if name.find("manifest.v3") >= 0:
for line in zf.read(name).split("\n"):
for match in re.findall(r'<value name="version">([0-9].*?)</value>',line):
parts=match.split(".")
localVersion=parts[1]
print localVersion
zf.close()
The code above works good, but sometimes on the zipfile i have the manifest.v3 file and manifest.v3.old, manifest.v3.old.old and so on.
How can I guarantee that I only get the result of the manifest.v3 file? instead all others?
try by changing the condition
name.find("manifest.v3") >= 0toname == "manifest.v3"Added a few examples below