Python预提交钩子,正在查找某些tex的行

2024-09-27 09:37:01 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,我的问题是关于一个Python脚本,我正试图开始工作。关键在于,当某人提交SVN时,他们会看到一个包含四行代码的登录模板:BranchBug_NumberFeature affected和{}。现在我尝试编写一个脚本,以确保他们在上面写了一些东西,以确保没有人输入空日志来提交。在

以下是我到目前为止在python中得到的基于一个旧python脚本的内容。在

    print "Importing the items"

import re  
 import sys  
 import os   

print "Initializing the list."  

argsList = []  
 hndFile = open(sys.argv[1],"r")  
 for line in hndFile:  
 argsList.append(line)  
 hndFile.close()   

print "Checking what is blank"  
 faOK = ovOK = False  
 for line in argsList:  
 line = line.strip()  
 if line.startswith('FEATURE_AFFECTED:'):  
 faOK = line[17:] != ''    
 if line.startswith('OVERVIEW:'):  
 ovOK = line[9:] != ''   

if not faOK:      
 print "You Must Enter the Feature Affected"    
 ret = -1  
 elif not ovOK:  
 print "You Must Enter an Overview of the Fix"  
 ret = -1    
 else:  
 ret = 0  
 print "Finishing the script"  
 sys.exit(ret)   

任何建议都会有帮助。我正在使用Windows XP,目前没有任何变化。我也在使用collabnet svn。目前,当我尝试运行这个脚本时,没有发生任何事情。我知道我没有在脚本中添加svnlook,我真的想不出在哪里添加以及为它添加变量。非常感谢。在


Tags: theinimport脚本forifsysline

热门问题