Dmitri Lebedev avatar Dmitri Lebedev committed 0a47b27 Draft

new recur_find

Comments (0)

Files changed (2)

fsquass/__init__.py

 		return result
 
 	def _recur_find(self, patterns):
-		pattern = patterns.pop(0)
-		result = self._nested_find(pattern)
-
+		result = self
 		for p in patterns:
-			result = result._nested_find(pattern)
+			result = result._nested_find(p)
+		child = self.children()
+		if len(child):
+			result |= child._recur_find(patterns)
+		return result
 
 	def _nested_find(self, pattern):
 		result = self
 
 class NewTestsCase(MockMixin, TestCase):
 	def test_new_search_funcs(self):
-		self.assertEqual(Fs([Dir('/')])._nested_find(['home', 'siberiano']), Fs('/home/siberiano'))
-		self.assertEqual(Fs([Dir('/home')])._nested_find(['..', 'tmp']), Fs('/tmp'))
+		self.assertEqual(Fs([Dir('/')])._nested_find(['home', 'siberiano']), Fs([File('/home/siberiano')]))
+		self.assertEqual(Fs([Dir('/home')])._nested_find(['..', 'tmp']), Fs([File('/tmp')]))
 		source = Fs([File('/home'), File('/tmp')])
 		target = Fs([File('/home/siberiano'), File('/tmp/siberiano')])
 		self.assertEqual(source._nested_find(['siberiano']), target)
+
+	def test_recur_find(self):
+		self.assertEqual(Fs([Dir('/')])._recur_find([['siberiano']]), Fs([Dir('/home/siberiano'), Dir('/tmp/siberiano')]))
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.