| 9 | |
| 10 | |
| 11 | class XPathExpr(XPathExprOrig): |
| 12 | |
| 13 | def __init__(self, path='', element='*', condition='', star_prefix=False): |
| 14 | self.path = path |
| 15 | self.element = element |
| 16 | self.condition = condition |
| 17 | self.post_condition = None |
| 18 | |
| 19 | def add_post_condition(self, post_condition): |
| 20 | if self.post_condition: |
| 21 | self.post_condition = '%s and (%s)' % (self.post_condition, |
| 22 | post_condition) |
| 23 | else: |
| 24 | self.post_condition = post_condition |
| 25 | |
| 26 | def __str__(self): |
| 27 | path = XPathExprOrig.__str__(self) |
| 28 | if self.post_condition: |
| 29 | path = '%s[%s]' % (path, self.post_condition) |
| 30 | return path |
| 31 | |
| 32 | def join(self, combiner, other, |
| 33 | closing_combiner=None, has_inner_condition=False): |
| 34 | res = XPathExprOrig.join(self, combiner, other, |
| 35 | closing_combiner=closing_combiner, |
| 36 | has_inner_condition=has_inner_condition) |
| 37 | self.post_condition = other.post_condition |
| 38 | return res |
| 39 | |
| 40 | |
| 41 | # keep cssselect < 0.8 compat for now |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…