#!/usr/bin/python import sys import re # Match the format we use to find # where entries begin date_regex = re.compile("\d{2} \w{3} \d{4};") # + is used in package names (for example gtk+) so try to handle that ebuild_regex = re.compile("((,|\s)\+[\S\+]+\.ebuild)") def check_changelog(file): f = open(file) lines = f.readlines() n=0 length = len(lines) file_printed = False while n < length: line = lines[n] if date_regex.search(line): while True: for m in ebuild_regex.findall(line): # remove + and trailing .ebuild to_find = m[0][2:-7] i = n-1 match = False while i >= 0 and not match: match = lines[i].startswith("*" + to_find) i-=1 if not match: if not file_printed: print file + " is missing *${P} (date) entries for:" file_printed = True print "\tnew ebuild entry on line " + str(n+1) n+=1 if line.find(":") >= 0 or n == length: break line = lines[n] n+=1 f.close() for ch in sys.argv[1:]: check_changelog(ch)