Commits

Walter Dörwald committed 4f861ed

Reverted the change to all, because this will hide nodes that should
be produced in certain cases, e.g. when a node is in the tree in multiple
locations, e.g. html.div(list("1234567890")).withsep(", ")/xsc.Node would
produce the ", " node only once. Fixing this is not simple so reverting
to the simple code.

Comments (0)

Files changed (3)

 <section><title>Changes in 2.6.? (released ??/??/2004)</title>
 <ulist>
 <item>Fixed a bug in <method>ll.xist.xfind.Finder.__floordiv__</method>.</item>
-<item>Multiple <lit>all</lit> operators in an XFind expression will now
-no longer produced duplicate nodes.</item>
 </ulist>
 </section>
 
 
 
 class all(Operator):
-	def xfind(self, iterator, *operators):
-		ids = {} # FIXME: Use a set in Python 2.4
-		for child in self.xwalk(iterator):
-			for subchild in Finder(child, *operators):
-				if id(subchild) not in ids:
-					ids[id(subchild)] = None
-					yield subchild
-
 	def xwalk(self, iterator):
 		for child in iterator:
 			for subchild in child.walk():
 		)
 
 
-class XFindTest1(unittest.TestCase):
+class XFindTestLevels(unittest.TestCase):
 	def setUp(self):
 		ds = [html.div(id=id) for id in xrange(8)]
 		ds[1].append(ds[4:7])
 		self.checkids(self.divs[0]//xfind.contains(html.div), "012")
 
 
-class XFindTest2(unittest.TestCase):
+class XFindTestOperators(unittest.TestCase):
 	def setUp(self):
 		self.node = xsc.Frag(
 			html.div(
 		self.assert_(res[0] is self.node[1]["class_"])
 
 
-class XFindTest3(unittest.TestCase):
-	def setUp(self):
-		ds = [html.div(id=hex(id).lower()[2:]) for id in xrange(15)]
-		for i in xrange(7):
-			ds[i].append(ds[2*i+1:2*i+3])
-		self.divs = ds
+class XFindTestMisc(unittest.TestCase):
+	def checkids(self, expr, ids):
+		self.assertEqual("".join([str(e["id"]) for e in expr]), ids)
+
+	def test_frag(self):
+		e = parsers.parseString("das ist <b>klaus</b>. das ist <b>erich</b>", prefixes=xsc.Prefixes(html))
+		# The following won't generate any nodes, because e/xfind.all iterates all
+		# nodes in the tree (but not the Frag root) and ../html.b filters the bold
+		# *children*, but there are none.
+		self.assertEqual(u"".join(map(unicode, e//html.b)), u"")
+		# The following *will* produce these nodes
+		self.assertEqual(u"".join(map(unicode, e//xfind.is_(html.b))), u"klauserich")
+
+	def test_multiall(self):
 		#        ____0____
 		#       /         \
 		#     _1_         _2_
 		#   3     4     5     6
 		#  / \   / \   / \   / \
 		# 7   8 9   a b   c d   e
-
-	def tearDown(self):
-		del self.divs
-
-	def checkids(self, expr, ids):
-		self.assertEqual("".join([str(e["id"]) for e in expr]), ids)
-
-	def test_frag(self):
-		e = parsers.parseString("das ist <b>klaus</b>. das ist <b>erich</b>", prefixes=xsc.Prefixes(html))
-		# The following won't generate any nodes, because e/xfind.all iterates all
-		# nodes in the tree (but not the Frag root) and ../html.b filter the bold
-		# children, but there are none.
-		self.assertEqual(u"".join(map(unicode, e//html.b)), u"")
-		# The following *will* produce these nodes
-		self.assertEqual(u"".join(map(unicode, e//xfind.is_(html.b))), u"klauserich")
-
-	def test_multiall(self):
-		self.checkids(self.divs[0]//html.div//html.div, "34789a56bcde")
+		ds = [html.div(id=hex(id).lower()[2:]) for id in xrange(15)]
+		for i in xrange(7):
+			ds[i].append(ds[2*i+1:2*i+3])
+		# Using // multiple times might produce certain nodes twice
+		self.checkids(ds[0]//html.div//html.div, "34789a56bcde789abcde")
 
 
 def test_main():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.