[Pythonmac-SIG] Stupid OS.WALK tricks?

Jay Painter jpaint@sculpin.com
Tue, 13 Nov 2001 09:38:15 -0800 (PST)


Just raise an exception in you os.walk callback like:

raise os.error, "stop it!!!"


On Tue, 13 Nov 2001, Schollnick, Benjamin wrote:

> Folks,
> 
> 	I'm attempting to optimize a quick program, but os.walk
> 	is sort of interferring...
> 	
> 	I'm searching a directory tree for graphic file.... using
> 	os.walk, and when it finds the file, it copies it to a local
> 	directory...
> 
> 	The "problem" here, is that I can't figure out how to
> 	stop OS.walk (in the visit function) from "continuing" 
> 	through the rest of the directories, and to just move 
> 	on to the next file... (There should only be one match)..
> 
> 	I figure I'm going to have to write a custom walk to
> 	deal with this scenario....  Does anyone have anything
> 	similiar?  Or suggestions on dealing with this?
> 
> 	Doing a "return" or "Break" during the search doesn't seem
> 	to do this....
> 
> 			- Benjamin
> 			- Benjamin
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>