]> git.ozlabs.org Git - patchwork/blobdiff - patchwork/parser.py
patchwork/models: Use OneToOneField for PatchChangeNotifcation.patch
[patchwork] / patchwork / parser.py
index a51a7b609af0c1df36a85f0d9fac4670efd9322e..8afb3348cee38c2c2e9f1eacfd9df26b8bd43ccf 100644 (file)
@@ -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