summaryrefslogtreecommitdiff
path: root/patterns.py
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2008-07-18 15:04:55 -0600
committerJonathan Corbet <corbet@lwn.net>2008-07-18 15:04:55 -0600
commitba5f6b69435f70ceaed738906c8ed7a4a87dc61b (patch)
tree2d5b89f73ddd1dea9c1ae55e7f09c87613328d7b /patterns.py
parent6eb60baac3247ac92b57f87319d3e261d24aca6b (diff)
Move regular expressions out to patterns.py
...I need them for an associated tool I'm working on.
Diffstat (limited to 'patterns.py')
-rw-r--r--patterns.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/patterns.py b/patterns.py
new file mode 100644
index 0000000..b056f1d
--- /dev/null
+++ b/patterns.py
@@ -0,0 +1,26 @@
+#
+# Pull together regular expressions used in multiple places.
+#
+import re
+
+#
+# Some people, when confronted with a problem, think "I know, I'll use regular
+# expressions." Now they have two problems.
+# -- Jamie Zawinski
+#
+Pcommit = re.compile (r'^commit ([0-9a-f ]+)$')
+Pauthor = re.compile (r'^Author: ([^<]+)\s<([^>]+)>$')
+Psob = re.compile (r'Signed-off-by:\s+([^<]+)\s+<([^>]+)>')
+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+(.*)$')
+
+#
+# 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)? '.*$")