mirror of
https://github.com/ciromattia/kcc
synced 2026-10-09 19:12:31 +00:00
Added Metadata editor class
This commit is contained in:
@@ -22,6 +22,9 @@ from html.parser import HTMLParser
|
||||
from distutils.version import StrictVersion
|
||||
from scandir import walk
|
||||
from time import sleep
|
||||
from shutil import rmtree, move
|
||||
from tempfile import mkdtemp
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
|
||||
|
||||
class HTMLStripper(HTMLParser):
|
||||
@@ -87,6 +90,20 @@ def saferReplace(old, new):
|
||||
raise PermissionError
|
||||
|
||||
|
||||
def removeFromZIP(zipfname, *filenames):
|
||||
tempdir = mkdtemp('', 'KCC-TMP-')
|
||||
try:
|
||||
tempname = os.path.join(tempdir, 'KCC-TMP.zip')
|
||||
with ZipFile(zipfname, 'r') as zipread:
|
||||
with ZipFile(tempname, 'w', compression=ZIP_DEFLATED) as zipwrite:
|
||||
for item in zipread.infolist():
|
||||
if item.filename not in filenames:
|
||||
zipwrite.writestr(item, zipread.read(item.filename))
|
||||
move(tempname, zipfname)
|
||||
finally:
|
||||
rmtree(tempdir)
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
def dependencyCheck(level):
|
||||
missing = []
|
||||
|
||||
Reference in New Issue
Block a user