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


Groups > comp.lang.python > #40114

Re: How to edit offline vmx file using python

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 <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'offline': 0.03; 'subject:file': 0.07; 'subject:How': 0.09; 'subject:using': 0.09; 'subject:python': 0.11; '"o"': 0.16; 'lowercase': 0.16; 'spacing': 0.16; 'subject:edit': 0.16; 'string': 0.17; 'wrote:': 0.17; 'skip:v 30': 0.20; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'values': 0.26; 'am,': 0.27; 'replace': 0.27; 'character': 0.29; 'file': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'updated': 0.34; 'there': 0.35; 'list.': 0.35; 'but': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'two': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'containing': 0.61; 'email addr:gmail.com': 0.63; 'equals': 0.65; 'harder': 0.65; 'received:74.208': 0.71; '16th': 0.84; 'differences,': 0.84
Date Thu, 28 Feb 2013 01:38:34 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: How to edit offline vmx file using python
References <fc5064fb-3119-4aa6-ae2f-e7c23dd13196@googlegroups.com>
In-Reply-To <fc5064fb-3119-4aa6-ae2f-e7c23dd13196@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:qobCsYNZGi0sEzjmlL7klttF/GmxKkP4NrSWDH0HrQv BSUVaovRHY1CBtCDu9mpyFWSAgi30kwjGxXz+M817KL5psMLEP rog8DHv7sExl4q7GUxba3bK1lOeL/5ACKigK9CIZvcJ+OP3xas Us0mzPjE76wonQ9q9PL76JhxVNWJvcXnkpsNMRcGmdugPD0wuZ qpN9dtatA+cjLbBGDvuHcn50HBgD7BOzIK/BfphIq3H486SWzM exGKtN38QUgXR4NLYmAVqvWLff5FRErm4DB9RPIXZQPwU6IK4F GIObDIv5Y+043IM/yPVT6CTzL8FFi0X5EicuF9jGSAxQnm8tQ= =
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.2640.1362033540.2939.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362033540 news.xs4all.nl 6905 [2001:888:2000:d::a6]:47197
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40114

Show key headers only | View raw


On 02/28/2013 12:29 AM, sasikiran2k7@gmail.com wrote:
> Hi,
>
> I am new to python, how can we edit a .vmx file offline or just simply a file containing the data in the below format.
>
> My file sample.vmx contains data
>
> pciBridge7.virtualDev = "pcieRootPort"
> pciBridge7.functions = "8"
> vmci0.present = "TRUE"
> hpet0.present = "TRUE"
> nvram = "testvmdk.nvram"
> virtualHW.productCompatibility = "hosted"
> powerType.powerOff = "soft"
> powerType.powerOn = "hard"
>
>
> I need to update those values and the updated file should contains the data
>
> pciBridge7.virtualDev = "pcieRootPort"
> pciBridge7.functions = "8"
> vmci0.present = "TRUE"
> hpet0.present = "TRUE"
> nvram = "testing.nvram"
> virtualHW.productCompatibility = "hosted"
> powerType.poweroff='hard"
> powerType.poweron="sof't"
>
>

Since the file is tiny, start by reading it all into memory, into a 
list.  Then replace last two line's 16th character with a lowercase "O" 
  And replace the last line's string following the equals sign with the 
string "\"sof't\"

There are also some spacing differences, but they're harder to describe, 
and I suspect they were accidental.

-- 
DaveA

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


Thread

How to edit offline vmx file using python sasikiran2k7@gmail.com - 2013-02-27 21:29 -0800
  Re: How to edit offline vmx file using python Dave Angel <davea@davea.name> - 2013-02-28 01:38 -0500

csiph-web