Re: [Tutor] find and replace relative to an nearby search string

2009-07-13 Thread pedro
Hi and thanks everyone for the enlightenment. I guess pyparsing is the way to go then. I just installed it and am trying it out. It looks good for all the stuff I need to do in Nuke frequently. I am going to do a bit of testing with Paul's solution. Cheers Pete __

Re: [Tutor] find and replace relative to an nearby search string in afile

2009-07-13 Thread Alan Gauld
"Pete O'Connell" wrote I am always looking for the line " name Write1" as my starting point. In the first example below, I want to replace the path, which is 2 lines above it. I have made a basic script to do that and it works fine. The problem I am having is when the number of lines between

Re: [Tutor] find and replace relative to an nearby search string

2009-07-13 Thread Paul McGuire
This is a good little pyparsing exercise. Pyparsing makes it easy to define the structure of a "Write { ( )* }" block, and use the names given to the parsed tokens to easily find the "name" and "file" entries. from pyparsing import (Literal, Word, alphanums, empty, restOfLine, dictOf) # make up

Re: [Tutor] find and replace relative to an nearby search string in a file

2009-07-13 Thread A.T.Hofkamp
Pete O'Connell wrote: Write { file /Volumes/raid0/Z353_002_comp_v27.%04d.cin file_type cin name Write1 xpos 13762 ypos -364 } The simplest approach imho is to parse the input with a proper parser, eg PLY or pyparsing. If you want to do the parsing manually, I'd start by classifying eac