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: 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 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: In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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