aboutsummaryrefslogtreecommitdiff
path: root/mammoth/document_matchers.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-29 21:42:49 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-29 21:42:49 +0000
commit85235a9cf69f847c2451eacaf44a242e6433937a (patch)
treef87a13301a134dc10f3190ecbb7a6d45e23f89ae /mammoth/document_matchers.py
parent15984eb246379f80050ee2bd816dc9bb2a1ffc5f (diff)
Introduce string matchers for matching style name
Diffstat (limited to 'mammoth/document_matchers.py')
-rw-r--r--mammoth/document_matchers.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mammoth/document_matchers.py b/mammoth/document_matchers.py
index 2efd73f..af1fd47 100644
--- a/mammoth/document_matchers.py
+++ b/mammoth/document_matchers.py
@@ -1,5 +1,7 @@
import collections
+import cobble
+
def paragraph(style_id=None, style_name=None, numbering=None):
return ParagraphMatcher(style_id, style_name, numbering)
@@ -35,3 +37,22 @@ class strikethrough(object):
class comment_reference(object):
element_type = "comment_reference"
+
+
+def equal_to(value):
+ return StringMatcher(_operator_equal_to, value)
+
+
+def _operator_equal_to(first, second):
+ return first.upper() == second.upper()
+
+
+@cobble.data
+class StringMatcher(object):
+ operator = cobble.field()
+ value = cobble.field()
+
+ def matches(self, other):
+ return self.operator(self.value, other)
+
+