From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] replace tabs with spaces of Python code Date: Wed, 18 May 2005 15:43:50 -0500 Message-ID: <428BA906.80204@us.ibm.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030405060803080209090207" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Pratt Cc: xen-devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------030405060803080209090207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ian Pratt wrote: > > > > >>there are many Python codes in tools/ that mix tab and space >>for indentation, which might introduce some silly and hidden >>bugs. this is a serious problem and must be avoid at all cost. >> >>here is a patch (against cset 1.1452) to replace all tabs with spaces. >>all the changes are pretty trivial, and i double checked everything. >>please take a look to see if all the modifies are OK. >> >>Signed-off-by: Nguyen Anh Quynh >> >> > >Are you sure python interprets a tab as a 4 spaces? I thought it >interpretted it as 8? > > It's not that simple. Check out 2.1.8 of the python language spec. http://docs.python.org/ref/indentation.html Tabs are expanded to the next 8 character column. The following script expands tabs as described in the python standard. I don't know how to do tab expansion in sed. Regards, Anthony Liguori Signed-off-by: Anthony Liguori >Hmm, there are a whole bunch of outstanding xend patches this this is >going to create merge hell for, so I'm not sure we want to apply this >straight away. > >Could you just post the script you used, or did you just do the obvious >sed invocation? > >Thanks, >Ian > > > >>any idea? if nobody complains, i would prepare a patch like >>this for -testing tree. >> >> >>$ diffstat removetab.patch >> logging/logging-0.4.9.2/test/mymodule.py | 6 +- >> xen/sv/CreateDomain.py | 34 ++++++++-------- >> xen/sv/Daemon.py | 2 >> xen/sv/DomInfo.py | 55 >>++++++++++++-------------- >> xen/sv/DomList.py | 16 +++---- >> xen/sv/GenTabbed.py | 6 +- >> xen/sv/HTMLBase.py | 4 - >> xen/sv/Main.py | 12 ++--- >> xen/sv/NodeInfo.py | 16 +++---- >> xen/sv/Wizard.py | 64 >>+++++++++++++++---------------- >> xen/sv/util.py | 6 +- >> xen/web/SrvBase.py | 6 +- >> xen/web/SrvDir.py | 2 >> xen/xend/EventServer.py | 24 +++++------ >> xen/xend/PrettyPrint.py | 6 +- >> xen/xend/XendClient.py | 6 +- >> xen/xend/XendDomain.py | 4 - >> xen/xend/encode.py | 2 >> xen/xend/server/SrvDomain.py | 6 +- >> xen/xend/sxp.py | 2 >> xen/xm/main.py | 12 ++--- >> 21 files changed, 143 insertions(+), 148 deletions(-) >> >>-- >>regards, >>aq >> >> >> > >_______________________________________________ >Xen-devel mailing list >Xen-devel@lists.xensource.com >http://lists.xensource.com/xen-devel > > > --------------030405060803080209090207 Content-Type: application/x-python; name="tab2space.py" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="tab2space.py" IyEvYmluL2VudiBweXRob24KCmltcG9ydCBzeXMKCmlmIGxlbihzeXMuYXJndikgPCAyOgog ICAgcHJpbnQgIlVzYWdlOiAlcyBJTlBVVCIgJSAoc3lzLmFyZ3ZbMF0pCiAgICBzeXMuZXhp dCgxKQoKZGF0YSA9IG9wZW4oc3lzLmFyZ3ZbMV0pLnJlYWQoKQoKY291bnQgPSAwCgp0YWJz aXplID0gOAoKZm9yIGNoIGluIGRhdGE6CiAgICBpZiBjaCA9PSAnXG4nOgogICAgICAgIHN5 cy5zdGRvdXQud3JpdGUoY2gpCiAgICAgICAgY291bnQgPSAwCiAgICBlbGlmIGNoID09ICdc dCc6CiAgICAgICAgbmV3Y291bnQgPSBjb3VudCArIHRhYnNpemUKICAgICAgICBuZXdjb3Vu dCAtPSBuZXdjb3VudCAlIHRhYnNpemUKICAgICAgICBmb3IgaSBpbiByYW5nZShuZXdjb3Vu dCAtIGNvdW50KToKICAgICAgICAgICAgc3lzLnN0ZG91dC53cml0ZSgnICcpCiAgICAgICAg Y291bnQgPSBuZXdjb3VudAogICAgZWxzZToKICAgICAgICBzeXMuc3Rkb3V0LndyaXRlKGNo KQogICAgICAgIGNvdW50ICs9IDEK --------------030405060803080209090207 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------030405060803080209090207--