[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Is there a better way to do this?

Matt Mitchell

3/1/2010 5:21:00 PM

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
1 Answer

Richard Brodie

3/1/2010 5:48:00 PM

0


"Matt Mitchell" <mmitchell@transparent.com> wrote in message
news:mailman.65.1267464765.23598.python-list@python.org...
> 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.