comparison genshi/path.py @ 593:aa5762c7b7f1

Minor, cosmetic tweaks.
author cmlenz
date Mon, 13 Aug 2007 21:38:46 +0000
parents cccb6c748609
children bc5faca93699
comparison
equal deleted inserted replaced
592:7145e4eba2ec 593:aa5762c7b7f1
37 Because the XPath engine operates on markup streams (as opposed to tree 37 Because the XPath engine operates on markup streams (as opposed to tree
38 structures), it only implements a subset of the full XPath 1.0 language. 38 structures), it only implements a subset of the full XPath 1.0 language.
39 """ 39 """
40 40
41 from math import ceil, floor 41 from math import ceil, floor
42 import operator
42 import re 43 import re
43 44
44 from genshi.core import Stream, Attrs, Namespace, QName 45 from genshi.core import Stream, Attrs, Namespace, QName
45 from genshi.core import START, END, TEXT, COMMENT, PI 46 from genshi.core import START, END, TEXT, COMMENT, PI
46 47
769 def __call__(self, kind, data, pos, namespaces, variables): 770 def __call__(self, kind, data, pos, namespaces, variables):
770 string1 = as_string(self.string1(kind, data, pos, namespaces, variables)) 771 string1 = as_string(self.string1(kind, data, pos, namespaces, variables))
771 string2 = as_string(self.string2(kind, data, pos, namespaces, variables)) 772 string2 = as_string(self.string2(kind, data, pos, namespaces, variables))
772 return re.search(string2, string1, self.flags) 773 return re.search(string2, string1, self.flags)
773 def _map_flags(self, flags): 774 def _map_flags(self, flags):
774 return reduce(lambda a, b: a | b, 775 return reduce(operator.or_,
775 [self.flag_map[flag] for flag in flags], re.U) 776 [self.flag_map[flag] for flag in flags], re.U)
776 def __repr__(self): 777 def __repr__(self):
777 return 'contains(%r, %r)' % (self.string1, self.string2) 778 return 'contains(%r, %r)' % (self.string1, self.string2)
778 779
779 class FalseFunction(Function): 780 class FalseFunction(Function):
Copyright (C) 2012-2017 Edgewall Software