aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-29 21:48:15 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-29 21:48:15 +0000
commitf6e7dac51adf4283c60df7ddc1500dd5e3215852 (patch)
treef6eefa9e8a96a8bbc5835aa1a95fe919f218b458 /mammoth
parent264a67f649cab578aaafea4b23bc38b05705a1ac (diff)
Add starts_with string matcher
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/document_matchers.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/mammoth/document_matchers.py b/mammoth/document_matchers.py
index af1fd47..d1f8e74 100644
--- a/mammoth/document_matchers.py
+++ b/mammoth/document_matchers.py
@@ -45,6 +45,14 @@ def equal_to(value):
def _operator_equal_to(first, second):
return first.upper() == second.upper()
+
+
+def starts_with(value):
+ return StringMatcher(_operator_starts_with, value)
+
+
+def _operator_starts_with(first, second):
+ return second.upper().startswith(first.upper())
@cobble.data
@@ -54,5 +62,3 @@ class StringMatcher(object):
def matches(self, other):
return self.operator(self.value, other)
-
-