Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99734

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Generate config file from template using Python search and replace.
Date Mon, 30 Nov 2015 10:14:16 +0100
Organization None
Lines 30
Message-ID <mailman.33.1448874871.14615.python-list@python.org> (permalink)
References <73046000-f634-40f2-9c83-f03a5db134e6@googlegroups.com> <mailman.3.1448752087.14615.python-list@python.org> <4f923003-4f85-4a69-bfda-165194211bb4@googlegroups.com> <mailman.11.1448837430.14615.python-list@python.org> <0dd0db34-7f8f-4e8b-ad6a-c82ad19c2e5e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace news.uni-berlin.de IHwNhZ4bP2NUVFGF2UtFFAIL7vsLZBi4djcCxcesntlA==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'cache': 0.05; 'that?': 0.05; 'subject:file': 0.07; 'braces': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'subject:using': 0.09; 'template': 0.11; 'question.': 0.13; 'options"': 0.16; 'options"),': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Generate': 0.16; 'subject:search': 0.16; '}}.': 0.16; 'wrote:': 0.16; '"you': 0.18; '2015': 0.20; 'permission': 0.20; 'skip:" 30': 0.20; 'posted': 0.21; 'referring': 0.22; 'sorry,': 0.22; 'words': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'sense': 0.26; 'see,': 0.27; 'went': 0.28; "i'm": 0.30; 'becomes': 0.30; 'supposed': 0.31; "can't": 0.32; 'run': 0.33; 'problem': 0.33; 'foo': 0.33; 'file': 0.34; 'replace': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; 'incorporate': 0.66; 'otten': 0.84
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57bd8d86.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:99734

Show key headers only | View raw


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 it into the script I posted?
>> 
>> Are you referring to my post? I'm sorry, I can't make sense of your
>> question.
> 
> Yes. The snippet you posted went way over my head. When I ran it, it
> printed
> 
> # permission sensitive cache
>   $include "_dispatcher_shared_auth-checker:

It's hard to tell from that problem description what might have gone wrong. 
However:

In your template file you have to enclose all words you want to replace in 
braces ("you have foo options" becomes "you have {foo} options"), to replace 
all literal { with {{ and all literal } with }}.

Did you do that?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-28 13:45 -0800
  Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-28 14:04 -0800
  Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-11-29 00:07 +0100
    Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 12:23 -0800
      Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-11-29 23:50 +0100
        Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 17:28 -0800
          Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-11-30 10:14 +0100
            Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-30 20:54 -0800
              Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-12-01 11:49 +0100
                Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-12-01 05:18 -0800
                Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-12-01 06:18 -0800
                Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-12-01 15:41 +0100
                Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-12-01 07:21 -0800
                Re: Generate config file from template using Python search and replace. Peter Otten <__peter__@web.de> - 2015-12-01 16:43 +0100
                Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-12-01 10:43 -0800
        Re: Generate config file from template using Python search and replace. Mr Zaug <matthew.herzog@gmail.com> - 2015-11-29 18:31 -0800
          Re: Generate config file from template using Python search and replace. Rob Hills <rhills@medimorphosis.com.au> - 2015-11-30 10:40 +0800
          Re: Generate config file from template using Python search and replace. MRAB <python@mrabarnett.plus.com> - 2015-11-30 03:23 +0000

csiph-web