diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-29 21:42:49 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-29 21:42:49 +0000 |
| commit | 85235a9cf69f847c2451eacaf44a242e6433937a (patch) | |
| tree | f87a13301a134dc10f3190ecbb7a6d45e23f89ae /mammoth/document_matchers.py | |
| parent | 15984eb246379f80050ee2bd816dc9bb2a1ffc5f (diff) | |
Introduce string matchers for matching style name
Diffstat (limited to 'mammoth/document_matchers.py')
| -rw-r--r-- | mammoth/document_matchers.py | 21 |
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) + + |
