X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=patchwork%2Fparser.py;h=8afb3348cee38c2c2e9f1eacfd9df26b8bd43ccf;hb=3b8a61c68fa61eadebf7b19329e8d3bffde9e6b4;hp=a51a7b609af0c1df36a85f0d9fac4670efd9322e;hpb=ad2762cf775a8dde508de47164d6429f3fd724f1;p=patchwork diff --git a/patchwork/parser.py b/patchwork/parser.py index a51a7b6..8afb334 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -21,6 +21,7 @@ import re +from collections import Counter try: import hashlib @@ -234,6 +235,14 @@ def hash_patch(str): return hash +def extract_tags(content, tags): + counts = Counter() + + for tag in tags: + regex = re.compile(tag.pattern, re.MULTILINE | re.IGNORECASE) + counts[tag] = len(regex.findall(content)) + + return counts def main(args): from optparse import OptionParser