本文主要是介绍汽车电子 -- python脚本组包软件版本号,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
python脚本组包软件版本号
import pandas as pd
import click
import os
import datetimedef cmdGetSwInfo():targetFilePath = '../APP.h'targetKeyWord = '#define'targetProgType = 'PROJECT_TYPE'targetSoftware = 'SOFTWARE_VERSION'targetVersionInfo = 'VERSION_INFO' fileRead = open(targetFilePath,'rb')for line in fileRead :line = line.decode("utf-8")if (targetKeyWord in line) and (targetProgType in line):line = line.replace(targetProgType,'')line = line.replace(targetKeyWord,'')currentProgType = line.strip()if (targetKeyWord in line) and (targetSoftware in line):line = line.replace(targetSoftware,'')line = line.replace(targetKeyWord,'')currentSoftware = line.strip() if (targetKeyWord in line) and (targetVersionInfo in line):line = line.replace(targetVersionInfo,'')line = line.replace(targetKeyWord,'')currentVersionInfo = line.strip() breakfileRead.close()current_date = datetime.datetime.now().strftime('_%Y%m%d') FileName = currentProgType + '_' + currentSoftware + '_' + currentVersionInfo + current_date + '.s19'print(name)if os.path.exists( name):os.rename('APP.s19', FileName)print("已合成\n")else:print("文件不存在,请重新生成.s19文件")print("文件名&版本号:", FileName)returnif __name__ == '__main__':name = 'APP.s19'cmdGetSwInfo()
APP.h
#define PROJECT_TYPE TEST
#define SOFTWARE_VERSION 0x00000001
#define VERSION_INFO App_Release
执行脚本:
会将脚本所在文件下的APP.s19文件 转换为
TEST_0x00000001_App_Release_20240822.s19
这篇关于汽车电子 -- python脚本组包软件版本号的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!