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


Groups > comp.lang.python > #30672

Re: parse an environment file

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jsf80238@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'bash': 0.07; 'skip:/ 10': 0.07; 'subject:file': 0.07; 'python': 0.09; 'novel': 0.09; 'subset': 0.09; 'looked': 0.10; 'itself.': 0.11; 'value.': 0.15; 'ah,': 0.16; 'chris,': 0.16; 'consciously': 0.16; 'enough.': 0.16; 'guessing': 0.16; 'config': 0.17; 'instance,': 0.17; 'solution.': 0.18; 'sender:addr:gmail.com': 0.18; 'variable': 0.20; 'received:209.85.216.46': 0.21; 'parse': 0.22; "i'd": 0.22; 'header:In-Reply-To:1': 0.25; 'restrict': 0.27; 'message- id:@mail.gmail.com': 0.27; 'post': 0.28; 'helpful.': 0.29; "i'm": 0.29; 'file': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'version': 0.34; 'received:google.com': 0.34; 'doing': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'but': 0.36; 'thank': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'range': 0.60; 'skip:u 10': 0.60; 'making': 0.64; 'yourself': 0.77; 'viable': 0.84; 'severe': 0.91; 'responses': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=a1fO5N62QDcrtgyiMUx8riyJgewwKwF6ykaINUPupVs=; b=YIGvKNem5qZsE1wL4xnwnTH4llC9qFH5VJM/Z+CxX6snZ4cb40O4iqfN0L+TYtlOXQ tn8DrvPHsqU8GJs5ZBln1nSd4t/DecA71Fe1rqQwwUyySk1RVKQ+EOUn4Fus79CNvAQe ot1q4WEoBcRyg4irl7lt08/FOYSl7EHsoPEpDJogo5PeA93tUuISUPWXU+NFMzcL1iXu NZfW17LORbDO0uHmX+WzzQDky92yWDj1Cz3FqGqvV2LdZRWeBb0ZQM3ij89WLVppc9l6 xRtvFvpZnw7RcRT7cXCt7DvGW++8X5cAKVEuPJ4LYVEBM1ywv5wmg0Q0URr/dk0WtEbE uRkg==
MIME-Version 1.0
Sender jsf80238@gmail.com
In-Reply-To <CAPTjJmq2p5FLq8_w35qguoBhckBTdohb419j_jCWuvTP9vjKog@mail.gmail.com>
References <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com> <CANy1k1g1dt6GQR80LWMkBt+YXzZXxtkUSV=qamWsS8mZXiyaAA@mail.gmail.com> <CAPTjJmrcsPgtcy6Aa5KJ8mRjFuB5b-FBanVQJ1o0M_PnHVpL2w@mail.gmail.com> <CANy1k1hzHqODvV7Eu64maOfCx8Os48wro56HG=uheyjqUos-uQ@mail.gmail.com> <CAPTjJmq2p5FLq8_w35qguoBhckBTdohb419j_jCWuvTP9vjKog@mail.gmail.com>
Date Tue, 2 Oct 2012 21:49:21 -0600
X-Google-Sender-Auth nF4hR9_wK_fMCBbqsNMHLMRFSrU
Subject Re: parse an environment file
From Jason Friedman <jason@powerpull.net>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1752.1349236170.27098.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349236170 news.xs4all.nl 6891 [2001:888:2000:d::a6]:49392
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30672

Show key headers only | View raw


> Ah, fair enough. Well, since you're using the full range of bash
> functionality, the only viable way to parse it is with bash itself.
> I'd recommend going with the version you have above:
>
>> * * * * * . /path/to/export_file && /path/to/script.py
>
> Under what circumstances is this not an option? That'd be the next
> thing to consider.
>
> Alternatively, you may want to consider making your own config file
> format. If you consciously restrict yourself to a severe subset of
> bash functionality, you could easily parse it in Python - for
> instance, always look for "export %s=%s" with simple strings for the
> variable name and value.
>
Thank you, Chris, off-list post unintentional.  It may be the case
that I do not maintain /path/to/export_file; I might just be allowed
to read it.
Based on your responses and everyone's responses I'm guessing that
what I am doing is sufficiently novel that there is no canned
solution.  I looked at shlex but did not see how that would be
helpful.
Thank you all for your thoughts.

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


Thread

Re: parse an environment file Jason Friedman <jason@powerpull.net> - 2012-10-02 21:49 -0600

csiph-web