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


Groups > comp.lang.python > #30604

Re: parse an environment file

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'skip:/ 10': 0.07; 'subject:file': 0.07; 'python': 0.09; 'script,': 0.09; 'looked': 0.10; 'feedback.': 0.15; 'to:name:python-list': 0.15; 'received:209.85.216.53': 0.16; 'variables': 0.17; 'sender:addr:gmail.com': 0.18; 'module': 0.19; 'question.': 0.20; 'are.': 0.22; 'work,': 0.22; 'this:': 0.23; 'header:In-Reply- To:1': 0.25; 'looks': 0.26; 'message-id:@mail.gmail.com': 0.27; 'this.': 0.29; "i'm": 0.29; 'code': 0.31; 'file': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'modules': 0.36; 'thank': 0.36; 'does': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'export': 0.62
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=RPasAfy2QgWp6gwOKetp5ENUwxgrHY6f1As3S/9z4c4=; b=IXYudXzQ/oqdijmjhxBoWmi+Q0DMfV9DpV7ZKEswLQsh+cjyjRHDZoSneE8Eva13r+ /DvoUGSoSBF8g6AMB3a6uK9sbDegY0M+Y+FHzcpIaz8Mrx4NmABpW/rFdl4TXpnjTTW3 pGKrO3iTe0pVzUdCClZJ+UIvFYur9JIaPKczHHj+uwTVVpAxUzWQd8hBBcMf47U9isKC DSdViYnEaM7LMetio6Mwy2wFEJD6y6uotLDQHWC+P3LhJQOIOimAfq0nDQkD+oh03cx7 Uxh1e0EevLjkAiXtu3Ggr8LpknK6TsgOH3kp/UEgs030TDOQ3eet/i3m81RZ3qKMQFjc PZhg==
MIME-Version 1.0
Sender jsf80238@gmail.com
In-Reply-To <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com>
References <CANy1k1i7XA3pTGeZeWk8V4osPkRoWxkSQJehhix9nHzDzO3HTg@mail.gmail.com>
Date Mon, 1 Oct 2012 08:12:50 -0600
X-Google-Sender-Auth qlj1L4AhFu9f5IHVbN6rXOjp2Mo
Subject Re: parse an environment file
From Jason Friedman <jason@powerpull.net>
To python-list <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.1703.1349100773.27098.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349100774 news.xs4all.nl 6892 [2001:888:2000:d::a6]:37756
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30604

Show key headers only | View raw


> I want my python 3.2.2 script, called via cron, to know what those
> additional variables are.  How?

Thank you for the feedback.  A crontab line of

* * * * * . /path/to/export_file && /path/to/script.py

does indeed work, but for various reasons this approach will not
always be available to me.

Let me restate my question.  I have a file that looks like this:
export VAR1=foo
export VAR2=bar
# Comment
export VAR3=${VAR1}${VAR2}

I want this:
my_dict = {'VAR1': 'foo', 'VAR2': 'bar', 'VAR3': 'foobar'}

I can roll my own, but I'm thinking there is a module or existing code
that does this.  I looked at the os and sys and configparse modules
but did not see it.

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


Thread

Re: parse an environment file Jason Friedman <jason@powerpull.net> - 2012-10-01 08:12 -0600
  Re: parse an environment file Hans Mulder <hansmu@xs4all.nl> - 2012-10-01 17:35 +0200
    Re: parse an environment file xDog Walker <thudfoo@gmail.com> - 2012-10-02 09:03 -0700
      Re: parse an environment file Ramchandra Apte <maniandram01@gmail.com> - 2012-10-02 09:16 -0700
      Re: parse an environment file Ramchandra Apte <maniandram01@gmail.com> - 2012-10-02 09:16 -0700

csiph-web