import database, csvdump, ConfigFile, reports
import getopt, datetime
import os, re, sys, rfc822, string
-from patterns import *
+from patterns import patterns
Today = datetime.date.today()
global NextLine
while (1):
- m = Pcommit.match (NextLine)
+ m = patterns['commit'].match (NextLine)
if m:
break;
NextLine = sys.stdin.readline ()
#
# If this line starts a new commit, drop out.
#
- m = Pcommit.match (Line)
+ m = patterns['commit'].match (Line)
if m:
break
NextLine = sys.stdin.readline ()
#
# Maybe it's an author line?
#
- m = Pauthor.match (Line)
+ m = patterns['author'].match (Line)
if m:
p.email = database.RemapEmail (m.group (2))
p.author = LookupStoreHacker(m.group (1), p.email)
#
# Could be a signed-off-by:
#
- m = Psob.match (Line)
+ m = patterns['signed-off-by'].match (Line)
if m:
email = database.RemapEmail (m.group (2))
sobber = LookupStoreHacker(m.group (1), email)
#
# Various other tags of interest.
#
- m = Preview.match (Line) # Reviewed-by:
+ m = patterns['reviewed-by'].match (Line)
if m:
email = database.RemapEmail (m.group (2))
p.addreviewer (LookupStoreHacker(m.group (1), email))
continue
- m = Ptest.match (Line) # Tested-by:
+ m = patterns['tested-by'].match (Line)
if m:
email = database.RemapEmail (m.group (2))
p.addtester (LookupStoreHacker (m.group (1), email))
p.author.testcredit (patch)
continue
- m = Prep.match (Line) # Reported-by:
+ # Reported-by:
+ m = patterns['reported-by'].match (Line)
if m:
email = database.RemapEmail (m.group (2))
p.addreporter (LookupStoreHacker (m.group (1), email))
p.author.reportcredit (patch)
continue
- m = Preptest.match (Line) # Reported-and-tested-by:
+ # Reported-and-tested-by:
+ m = patterns['reported-and-tested-by'].match (Line)
if m:
email = database.RemapEmail (m.group (2))
h = LookupStoreHacker (m.group (1), email)
#
# If this one is a merge, make note of the fact.
#
- m = Pmerge.match (Line)
+ m = patterns['merge'].match (Line)
if m:
p.merge = 1
continue
#
# See if it's the date.
#
- m = Pdate.match (Line)
+ m = patterns['date'].match (Line)
if m:
dt = rfc822.parsedate(m.group (2))
p.date = datetime.date (dt[0], dt[1], dt[2])
# OK, maybe it's part of the diff itself.
#
if not ignore:
- if Padd.match (Line):
+ if patterns['add'].match (Line):
p.added += 1
continue
- if Prem.match (Line):
+ if patterns['rem'].match (Line):
p.removed += 1
else:
# Get the statistics (lines added/removes) using numstats
# and without requiring a diff (--numstat instead -p)
- m = Pnumstat.match (Line)
+ m = patterns['numstat'].match (Line)
if m:
+ filename = m.group(3)
# If we have a file filter, check for file lines.
- if FileFilter and not FileFilter.search (m.group(3)):
+ if FileFilter and not FileFilter.search (filename):
continue
try:
- p.added += int(m.group(1))
- p.removed += int(m.group(2))
+ added = int(m.group(1))
+ removed = int(m.group(2))
except ValueError:
# A binary file (image, etc.) is marked with '-'
- pass
+ added = removed = 0
+
+ p.added += added
+ p.removed += removed
if '@' in p.author.name:
GripeAboutAuthorName (p.author.name)
# If this is the first file line (--- a/), set ignore one way
# or the other.
#
- m = Pfilea.match (line)
+ m = patterns['filea'].match (line)
if m:
file = m.group (1)
if FileFilter.search (file):
#
# For the second line, we can turn ignore off, but not on
#
- m = Pfileb.match (line)
+ m = patterns['fileb'].match (line)
if m:
file = m.group (1)
if FileFilter.search (file):
#
+# -*- coding:utf-8 -*-
# Pull together regular expressions used in multiple places.
#
# This code is part of the LWN git data miner.
#
# Copyright 2007-11 Eklektix, Inc.
# Copyright 2007-11 Jonathan Corbet <corbet@lwn.net>
+# Copyright 2011 Germán Póo-Caamaño <gpoo@gnome.org>
#
# This file may be distributed under the terms of the GNU General
# Public License, version 2.
# expressions." Now they have two problems.
# -- Jamie Zawinski
#
-Pemail = r'\s+"?([^<"]+)"?\s<([^>]+)>' # just email addr + name
-Pcommit = re.compile (r'^commit ([0-9a-f ]+)$')
-Pauthor = re.compile (r'^Author:' + Pemail + '$')
-Psob = re.compile (r'^\s+Signed-off-by:' + Pemail + '.*$')
-Pmerge = re.compile (r'^Merge:.*$')
-Padd = re.compile (r'^\+[^+].*$')
-Prem = re.compile (r'^-[^-].*$')
-Pdate = re.compile (r'^(Commit)?Date:\s+(.*)$')
-Pfilea = re.compile (r'^---\s+(.*)$')
-Pfileb = re.compile (r'^\+\+\+\s+(.*)$')
-Preview = re.compile (r'^\s+Reviewed-by:' + Pemail + '.*$')
-Ptest = re.compile (r'^\s+tested-by:' + Pemail + '.*$', re.I)
-Prep = re.compile (r'^\s+Reported-by:' + Pemail + '.*$')
-Preptest = re.compile (r'^\s+reported-and-tested-by:' + Pemail + '.*$', re.I)
-#
-# Merges are described with a variety of lines.
-#
-PExtMerge = re.compile(r'^ +Merge( branch .* of)? ([^ ]+:[^ ]+)\n$')
-PIntMerge = re.compile(r'^ +(Merge|Pull) .* into .*$')
-# PIntMerge2 = re.compile(r"^ +Merge branch(es)? '.*$")
-PIntMerge2 = re.compile(r"^ +Merge .*$")
-#
-# Another way to get the statistics (per file). It implies --numstat
-Pnumstat = re.compile('^(\d+|-)\s+(\d+|-)\s+(.*)$')
-Prename = re.compile('(.*)\{(.*) => (.*)\}(.*)')
+_pemail = r'\s+"?([^<"]+)"?\s<([^>]+)>' # just email addr + name
+
+patterns = {
+ 'commit': re.compile (r'^commit ([0-9a-f ]+)$'),
+ 'author': re.compile (r'^Author:' + _pemail + '$'),
+ 'signed-off-by': re.compile (r'^\s+Signed-off-by:' + _pemail + '.*$'),
+ 'merge': re.compile (r'^Merge:.*$'),
+ 'add': re.compile (r'^\+[^+].*$'),
+ 'rem': re.compile (r'^-[^-].*$'),
+ 'date': re.compile (r'^(Commit)?Date:\s+(.*)$'),
+ # filea, fileb are used only in 'parche mode' (-p)
+ 'filea': re.compile (r'^---\s+(.*)$'),
+ 'fileb': re.compile (r'^\+\+\+\s+(.*)$'),
+ 'reviewed-by': re.compile (r'^\s+Reviewed-by:' + _pemail+ '.*$'),
+ 'tested-by': re.compile (r'^\s+tested-by:' + _pemail + '.*$', re.I),
+ 'reported-by': re.compile (r'^\s+Reported-by:' + _pemail + '.*$'),
+ 'reported-and-tested-by': re.compile (r'^\s+reported-and-tested-by:' + _pemail + '.*$', re.I),
+ #
+ # Merges are described with a variety of lines.
+ #
+ 'ExtMerge': re.compile(r'^ +Merge( branch .* of)? ([^ ]+:[^ ]+)\n$'),
+ 'IntMerge': re.compile(r'^ +(Merge|Pull) .* into .*$'),
+ # PIntMerge2 = re.compile(r"^ +Merge branch(es)? '.*$"),
+ 'IntMerge2': re.compile(r"^ +Merge .*$"),
+ # Another way to get the statistics (per file).
+ # It implies --numstat
+ 'numstat': re.compile('^(\d+|-)\s+(\d+|-)\s+(.*)$'),
+ 'rename' : re.compile('(.*)\{(.*) => (.*)\}(.*)'),
+}