Python question-string.find

I’m writing a utility to update egg files with relative pathnames, and I’m a bit stuck.
I’m using the string.find function to find the start of a texture reference.
What I want to find is:


I’m not sure if I need to include the cr/lf in the search string, and the ending quotes is a problem.
So what I need is: do I need to include the cr/lf in the search string, and how do I handle the quotes?

you can use single-quotes for that , like {" or “{’” if you need it the other way round.
you can use pythons replace() function to just get rid of all those whitespaces, tabs and newlines and then search for {"

EDIT: previous problem caused by a workaround, which had it’s problem fixed, so it was messing up the indices.

My new problem is how to convert this:
into this:

Hmm, I would personally use EggData classes for that, just load the .egg file, iterate through the nodes, replace all paths, and save it again.

Maybe you could do it with a smart regexp as well.
You could just search for “([a-zA-Z]):\” and replace it with “/$1/”, and find “\” and replace it with “/”.

The short answer to the question is, Filename(’/c/folder/texture.jpg’).toOsSpecific() -> ‘c:\folder\texture.jpg’, as described in the manual.

Of course you know that an egg file should contain filenames of the first form, not of the second form.


Thanks for the help, and yes, I know about egg texture filenames, I needed that conversion so I could get shutil to copy the texture file.