| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- # -*- coding: utf-8 -*-
- import xml.etree.ElementTree as ETree
- # cordova 配置文件地址
- cordova_xml = "./cordova/config.xml"
- # cordova 版本号替换文本
- replace = 'widget id="com.shotshock.twong" version="'
- def get_apk_version():
- conf = ETree.parse(cordova_xml)
- root = conf.getroot()
- apk_ver = root.get("version")
- print("local version: " + apk_ver)
- return apk_ver
- # 设置 cordova 配置中的 APP 版本号
- def apk_version(version):
- conf = ETree.parse(cordova_xml)
- root = conf.getroot()
- apk_ver = root.get("version")
- print("local version: " + apk_ver)
- conf = open(cordova_xml, "r")
- text = conf.read()
- conf.flush()
- conf.close()
- text = text.replace(replace + apk_ver, replace + version)
- new = open(cordova_xml, "w")
- new.write(text)
- new.flush()
- new.close()
- # 生成新的版本号
- def new_version(version):
- olds = version.split('.')
- new_2 = int(olds[2])
- new_1 = int(olds[1])
- new_0 = int(olds[0])
- if new_2 + 1 > 9:
- if new_1 + 1 > 9:
- new_0 = new_0 + 1
- new_1 = 0
- new_2 = 0
- else:
- new_1 = new_1 + 1
- new_2 = 0
- else:
- new_2 = new_2 + 1
- new = str(new_0) + "." + str(new_1) + "." + str(new_2)
- print("new version: " + new)
- return new
|