Is there a better way to do this?

M

Matt Mitchell

Hi,

I wrote a python script that uses pysvn to export projects from an svn
repo I have. The repo has hundreds of projects in it with a directory
structure that is pretty uniform however it's not exactly uniform
because of the capitalization. I.e.:
\root
\project English
\Stuff
\Stuff 2
\Project Spanish
\Stuff 3
\Stuff 4

My svn repo is case sensitive so if I try to get \root\project
Spanish\Stuff 3 I get an error. Fixing the capitalization is not an
option for me. My initial idea was to make a list of all the different
ways "project" has been capitalized in my repo and try each one. The
code looks like this:

import pysvn

def getstuff(stuffiwant, languageiwantitin):
projects = ("project %s/", "Project %s/", "pRojects %s/")
c = pysvn.Client()
for p in projects:
exportme = p % languageiwantitin
exportme = "http://localhost/" + exportme + stuffiwant
try:
c.export(exportme, "C:\\temp\\")
break
except pysvn.ClientError:
print "Not the right capitalization."
# do the rest of the stuff I need to do.

This works, but to me it seems like there has to be a better way of
doing it. Any feedback or suggestions would be appreciated.

Thanks,
Matt
 
R

Richard Brodie

Matt Mitchell said:
My initial idea was to make a list of all the different
ways "project" has been capitalized in my repo and try each one. The
code looks like this:

I would use pysvn.Client.list to get a list of files at whatever directory level
you require. Then you can do a case insensitive compare or whatever else.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top