#!/usr/bin/env python #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ """ Usage: setchange form-in change "/p4/common/bin/triggers/SetChangeRestricted.py %formfile%" This script is designed to run as a form-in trigger. It will add Type: restricted to the change form if it isn't already there. """ from __future__ import print_function import re import sys def set_changetype(formfile): with open(formfile) as f: content = f.read() if(not re.search("Type:\trestricted", content)): content = content + "\nType:\trestricted\n" with open(formfile, "w") as f: f.write(content) if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: SetLabelOptions.py ") sys.exit(0) set_changetype(sys.argv[1]) sys.exit(0)