tags:

views:

345

answers:

1

I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. How can I do this? I'm new to Python so a detailed response and/or point in the right direction would be very much appreciated.

Follow-up: When using os.walk what parameter would I pass in to ensure that I'm copying files with a specific extension (eg. *.exe)?

+1  A: 

I think it is easiest to check out (or, better, export) the source tree using the svn command line utility: you can use os.system to invoke it. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python.

You can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.

Martin v. Löwis
If the size of the repository is large and the desired files small then it makes more sense to use the python bindings. It doesn't sound like he'll be doing anything destructive to the repo.
Sam Corder
It's also a matter of effort. Using the bindings is fairly difficult, especially when you want to fetch files selectively. Performance might be of minor concern in his application.
Martin v. Löwis