7 Star 21 Fork 6

kodicn / repo-cn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
release.py 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
taxigps 提交于 2019-07-12 18:11 . release tools support python 3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" plugin release tool"""
import os, sys, re, zipfile, shutil
def cp(src, dst):
if os.path.exists(src):
shutil.copyfile(src, dst)
def release(plugin, version):
# zip dir
zipdir = 'repo/%s' % (plugin)
if not os.path.exists(zipdir):
os.mkdir(zipdir)
# zip repo
zipname = 'repo/%s/%s-%s.zip' % (plugin, plugin, version)
f = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
for dirpath, dirnames, filenames in os.walk(plugin):
for filename in filenames:
f.write(os.path.join(dirpath,filename))
f.close()
# copy icon
src = '%s/icon.png' % (plugin)
dst = 'repo/%s/icon.png' % (plugin)
cp(src, dst)
# copy change log
src = '%s/changelog.txt' % plugin
dst = 'repo/%s/changelog-%s.txt' % (plugin, version)
cp(src, dst)
def getVersion(plugin):
name = '%s/addon.xml' % plugin
if sys.version_info[0] >= 3:
cont = open(name,encoding='utf-8').read()
else:
cont = open(name).read()
addon = re.findall('<addon.*?version="(.*?)"', cont, re.DOTALL)
if addon:
return addon[0]
argc = len(sys.argv)
if argc >= 2:
plugin = sys.argv[1].rstrip('/')
version = getVersion(plugin) if argc == 2 else sys.argv[2]
release(plugin, version)
else:
print('usage: %s plugin_dir [plugin_version]' % sys.argv[0])
Python
1
https://gitee.com/kodicn/repo-cn.git
git@gitee.com:kodicn/repo-cn.git
kodicn
repo-cn
repo-cn
master

搜索帮助