# Trigger to block submission of changelists which contain any variation of # "do not submit" (case/spacing insensitive) on the first line of the changelist # description. # # Author: Joe Robinson # Created: 2013/06/26 # Edited: %% # File: DoNotSubmit.py from sys import argv import sys, re, marshal #filename, changelistNum, serverDirectory, dictionaryFile = argv # TEST PARAMS #----- valid = re.compile(r"^..(DO).(NOT).(SUBMIT)$") changelistNum = 0 dictionaryFile = open('text.txt', 'rb') dictionary = marshal.load(dictionaryFile) # Assign description field to string #----- descField = str(dictionary[b'desc']) print ("DESC: %s" % (descField)) re.sub('_', '') print("Top comment line is: %s" % "placeholderline") # Exit with error message if string is found. # if desc field matches regular expression: ^do.not.submit$ if (valid.match(descField)): print(" --- REJECTED submitted changelist.") sys.exit("PY script rejecting \'DO NOT SUBMIT\' changelist %i." % changelistNum) # Else if string is not found: print(" --- ACCEPTED submitted changelist %i." % changelistNum) sys.exit(0)