Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Ye, this does work. Many thanks! filename = "{NNN}_{BRAND}_farm.any".format(BRAND=brand, NNN=nnn) with open(filename, "w") as outstream: outstream.write(data) -- https://mail.python.org/mailman/listinfo/python-list

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Peter Otten
Mr Zaug wrote: > That makes sense. > > So I still can't see how to write the string object to a file whist naming > the file with whatever values I provided for the NNN and BRAND variables. > > Printing the contents of the string object is working with all the > expected substitutions. Do I need

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
That makes sense. So I still can't see how to write the string object to a file whist naming the file with whatever values I provided for the NNN and BRAND variables. Printing the contents of the string object is working with all the expected substitutions. Do I need to convert the string obje

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Peter Otten
Mr Zaug wrote: > Actually, I don't understand what you mean by "all other braces." What > braces are you talking about? The placeholders in the template file (the > file being read in) have braces around them but they are not escaped. The example you provide was $include "_dispatcher_publi

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Actually, I don't understand what you mean by "all other braces." What braces are you talking about? The placeholders in the template file (the file being read in) have braces around them but they are not escaped. Also, do I really need curly braces to tell Python what my placeholders are? --

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Oh, that's much easier to read. Thanks! -- https://mail.python.org/mailman/listinfo/python-list

Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Peter Otten
Mr Zaug wrote: > On Monday, November 30, 2015 at 4:14:48 AM UTC-5, Peter Otten wrote: >> Mr Zaug wrote: >> >> > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: >> >> Mr Zaug wrote: >> >> >> >> > When I run this script on OS X El Capitan, I see, >> >> > >> >> > # permiss

Re: Generate config file from template using Python search and replace.

2015-11-30 Thread Mr Zaug
On Monday, November 30, 2015 at 4:14:48 AM UTC-5, Peter Otten wrote: > Mr Zaug wrote: > > > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: > >> Mr Zaug wrote: > >> > >> > When I run this script on OS X El Capitan, I see, > >> > > >> > # permission sensitive cache > >> >

Re: Generate config file from template using Python search and replace.

2015-11-30 Thread Peter Otten
Mr Zaug wrote: > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: >> Mr Zaug wrote: >> >> > When I run this script on OS X El Capitan, I see, >> > >> > # permission sensitive cache >> > $include "_dispatcher_shared_auth-checker: >> > >> > Was I supposed to incorporate

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread MRAB
On 2015-11-30 02:40, Rob Hills wrote: A program I am writing at present does exactly this and I simply do multiple calls to string.replace (see below) On 30/11/15 10:31, Mr Zaug wrote: I seem to be heading in this direction. #!/usr/bin/env python import re from os.path import exists script, t

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Rob Hills
A program I am writing at present does exactly this and I simply do multiple calls to string.replace (see below) On 30/11/15 10:31, Mr Zaug wrote: > I seem to be heading in this direction. > > #!/usr/bin/env python > import re > from os.path import exists > > script, template_file = argv > print "

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: > Mr Zaug wrote: > > > When I run this script on OS X El Capitan, I see, > > > > # permission sensitive cache > > $include "_dispatcher_shared_auth-checker: > > > > Was I supposed to incorporate it into the script I poste

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote: > Mr Zaug wrote: > > > When I run this script on OS X El Capitan, I see, > > > > # permission sensitive cache > > $include "_dispatcher_shared_auth-checker: > > > > Was I supposed to incorporate it into the script I poste

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Peter Otten
Mr Zaug wrote: > When I run this script on OS X El Capitan, I see, > > # permission sensitive cache > $include "_dispatcher_shared_auth-checker: > > Was I supposed to incorporate it into the script I posted? Are you referring to my post? I'm sorry, I can't make sense of your question. -

Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
When I run this script on OS X El Capitan, I see, # permission sensitive cache $include "_dispatcher_shared_auth-checker: Was I supposed to incorporate it into the script I posted? -- https://mail.python.org/mailman/listinfo/python-list

Re: Generate config file from template using Python search and replace.

2015-11-28 Thread Peter Otten
Mr Zaug wrote: > I need to generate a config file based on an existing "template" file. I > need to replace a set of strings with other strings globally in the > generated file. > > Here is a snippet of the template file, where CONTENT_PATH and DAMPATH are > two "placeholders" or variables. There

Re: Generate config file from template using Python search and replace.

2015-11-28 Thread Mr Zaug
I should mention the template file is small, just 98 lines long and the working config file will be the same size. -- https://mail.python.org/mailman/listinfo/python-list