Re: Line replace

2006-01-01 Thread DarkBlue
Thank you for all the suggestions It appears the safest solution still is using a temp file as was so apt suggested further up here without it I maybe white water rafting without a canoe. I also will test the feasibility to regenerate the whole file from the database. Nx -- http://mail.python

Re: Line replace

2006-01-01 Thread Mike Meyer
DarkBlue <[EMAIL PROTECTED]> writes: > pseudocode is like this: > > get newlinetext from database # this is ok done with kinterbas > preferably check if file not in use by other process > open file and find desired marker > go to line after marker and replace that one with newlinetext > close the

Re: Line replace

2006-01-01 Thread DarkBlue
> OK, why don't you store those changing lines in the database? > > Can you arrange for those changeable lines to be fixed length, i.e. > by padding with spaces or something? If you can, then you could just > overwrite them in place. Use flock or fcntl (Un*x) or the comparable > Windows locking

Re: Line replace

2006-01-01 Thread Paul Rubin
DarkBlue <[EMAIL PROTECTED]> writes: > The markers are just there to have a static way to find the line > after the marker, which is the one which might have to be changed. OK, why don't you store those changing lines in the database? Can you arrange for those changeable lines to be fixed length,

Re: Line replace

2006-01-01 Thread DarkBlue
> Why don't you use the database to store those markers? It should > support concurrent updates properly. That's a database's job. The markers are just there to have a static way to find the line after the marker, which is the one which might have to be changed. Nx -- http://mail.python.org/m

Re: Line replace

2006-01-01 Thread Paul Rubin
DarkBlue <[EMAIL PROTECTED]> writes: > Now our authorized clients register themselves automatically with > computername,id and ip address via a small python script which sends this > information to a firebird database on our server... > Every client has a marker in the hosts.allow file > so if a ch

Re: Line replace

2006-01-01 Thread DarkBlue
Steven D'Aprano wrote: > Let me see if I understand your problem... you need to edit a text file > in place at the same time that another process is also changing the file > in place? That's hard. You need some way to decide who gets precedence if > both you and the other process both try to cha

Re: Line replace

2006-01-01 Thread Sam Pointon
>Hello > > I need some help > > I have a text file which changes dynamically and has > 200-1800 lines. I need to replace a line , this line > can be located via a text marker like : > > somelines > # THIS IS MY MARKER > This is the line to be replaced > somemorelines > > My question is how

Re: Line replace

2006-01-01 Thread Steven D'Aprano
On Sun, 01 Jan 2006 19:31:38 +0800, DarkBlue wrote: > Hello > > I need some help > > I have a text file which changes dynamically and has > 200-1800 lines. I need to replace a line , this line > can be located via a text marker like : > > somelines > # THIS IS MY MARKER > This is

Line replace

2006-01-01 Thread DarkBlue
Hello I need some help I have a text file which changes dynamically and has 200-1800 lines. I need to replace a line , this line can be located via a text marker like : somelines # THIS IS MY MARKER This is the line to be replaced somemorelines My question is how to do this