我正在尝试用当前构建版本更新我的.ism文件。查找和替换构建字符串没有问题。但是,我很难让我的.ism文件在被漂亮的汤处理后保持它的格式。下面是我尝试使用漂亮汤查找和更新构建版本字符串的尝试:
def upVerIsm(origFile,newFile):
openIsm = origFile
outputIsm = newFile
soup = BeautifulSoup(openIsm)
tblProp = soup.find("table", {"name":"Property"})
rows = tblProp.find_all("row")
for row in rows:
firstCell = row.contents[0].get_text()
if firstCell == "ProductVersion":
tmpProdVer = row.contents[1].string.replace_with(updVerStr)
if(flgMstrVer):
tblReg = soup.find("table", {"name":"Registry"})
# get all rows within registry table
rows = tblReg.find_all("row")
for row in rows:
td4 = row.contents[3].get_text()
if td4 == "MasterVersion":
td5 = row.contents[4].get_text()
tmpMstrStr = re.split('_',unicode(td5))
newBuildStr = tmpMstrStr[0] + "_" + tmpMstrStr[1] + "_" + tmpMstrStr[2] + "_B" + version_num
row.contents[4].string.replace_with(str(newBuildStr))
print row
# tmpIsm = soup.encode("ascii","ignore")
# updatedIsm = soup.prettify(formatter=None) # if i do this i get the ascii code error: (UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 666845: ordinal not in range(128))
updatedIsm = str(soup) # this alters the content of the .ism file and breaks the build
outputIsm.write(updatedIsm)
return outputIsm,openIsm # new,original files respectively我被困住了,想要一些指点,谢谢你的阅读!
发布于 2013-07-25 14:17:42
您不需要更新ISM,只需将构建版本(和许多其他内容)传递到编译器。如果您真的想更新ISM,那么InstallShield提供了一个自动化接口。打开项目,更新属性,然后保存和关闭项目。
而且,尽管我非常喜欢InstallShield,但ISM仅仅是底层MSI表数据的DTD XML转换。如果代码表达能力真的是您的首要任务,那么基于WiX的XSD是最好的选择。
https://stackoverflow.com/questions/17850620
复制相似问题