From f6e7dac51adf4283c60df7ddc1500dd5e3215852 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 29 Nov 2016 21:48:15 +0000 Subject: Add starts_with string matcher --- mammoth/document_matchers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mammoth') 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) - - -- cgit v1.2.3