X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=check_prefix.py;h=de561981c5f6f0491526457a0e84e3e5497274b8;hb=b86f63b78001aac653f72335b55a158ea411c330;hp=d4adcbcea69ad0f41cae3081bfa09acd881c4f4c;hpb=4fa9fa3d8b71afe054fa0a663d94e2a5910b631e;p=releng%2Fbuilder.git diff --git a/check_prefix.py b/check_prefix.py index d4adcbcea..de561981c 100755 --- a/check_prefix.py +++ b/check_prefix.py @@ -12,7 +12,7 @@ The production prefix MUST always be a blank string. """ -__author__ = 'Thanh Ha' +__author__ = "Thanh Ha" import os @@ -21,17 +21,18 @@ import sys def check_prefix(filename): - with open(filename, 'r') as _file: + """Check if a prefix was checked into this repo.""" + with open(filename, "r") as _file: for num, line in enumerate(_file, 1): - if re.search('prefix:', line): - if "''" not in line: + if re.search(r"^\s+prefix:", line): + if '""' not in line: print( - 'ERROR: A non-blank prefix is defined in ' - 'jjb/defaults.yaml. The prefix MUST be set to blank ' - '\'\' in production!' + "ERROR: A non-blank prefix is defined in " + "jjb/defaults.yaml. The prefix MUST be set to blank " + '"" in production!' ) sys.exit(1) if __name__ == "__main__": - check_prefix(os.path.join('jjb', 'defaults.yaml')) + check_prefix(os.path.join("jjb", "defaults.yaml"))