代码库初始化
This commit is contained in:
1 parent
07786ab323
commit
4334694551
851 files changed
+42626
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import zipfile, os, re, shutil
|
||||
|
||||
jar = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\309c2d420bc84ee986db9cdd070ff02a\_sa_hanhua_out\sa_lib-forge-1.20.1-1.0.1.jar'
|
||||
|
||||
with zipfile.ZipFile(jar) as z:
|
||||
infos = z.infolist()
|
||||
data = {i.filename: z.read(i) for i in infos}
|
||||
meta = 'META-INF/mods.toml'
|
||||
text = data[meta].decode('utf-8')
|
||||
|
||||
new_text = re.sub(
|
||||
r"description\s*=\s*'''[\s\S]*?'''",
|
||||
"description='''\n我们所有幸存者军火库模组的公共库。\n'''",
|
||||
text,
|
||||
count=1,
|
||||
)
|
||||
print('changed:', new_text != text)
|
||||
print(new_text[:400])
|
||||
if new_text != text:
|
||||
data[meta] = new_text.encode('utf-8')
|
||||
tmp = jar + '.tmp'
|
||||
with zipfile.ZipFile(tmp, 'w', zipfile.ZIP_DEFLATED) as z:
|
||||
for i in infos:
|
||||
z.writestr(i, data[i.filename])
|
||||
shutil.move(tmp, jar)
|
||||
print('jar updated.')
|
||||
|
||||
# verify
|
||||
with zipfile.ZipFile(jar) as z:
|
||||
t = z.read(meta).decode('utf-8')
|
||||
for line in t.splitlines():
|
||||
if 'displayName' in line or 'description' in line:
|
||||
print('VERIFY:', line.strip())
|
||||
print('entries=', len(z.namelist()), 'testzip=', z.testzip())
|
||||
Reference in new issue
Block a user