# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import hashlib
import re
-
-try:
- import hashlib
- sha1_hash = hashlib.sha1
-except ImportError:
- import sha
- sha1_hash = sha.sha
+from collections import Counter
_hunk_re = re.compile('^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@')
_filename_re = re.compile('^(---|\+\+\+) (\S+)')
str = str.strip() + '\n'
prefixes = ['-', '+', ' ']
- hash = sha1_hash()
+ hash = hashlib.sha1()
for line in str.split('\n'):
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