WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] replace tabs with spaces of Python code

To: aq <aquynh@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] replace tabs with spaces of Python code
From: Christian Limpach <christian.limpach@xxxxxxxxx>
Date: Thu, 19 May 2005 10:17:29 +0100
Cc: Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 19 May 2005 09:16:58 +0000
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=A+ZZp0Yp0B0LQTIrvcpBbA/WGYixdXwmKAuB9PQY1HOhbL5yZkYkqptn/qUhCszyGZ+V13cxRHF4vORvJ1mr5zQlp1JMDu+bUjEateqYUXuV6thQ0IAX4DYcGjkQKQ1aY1JVHei+3KTZB+XScfL+XNg9uLcmELajaZW7L3aY7Ds=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <9cde8bff05051819402d7b80e@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <A95E2296287EAD4EB592B5DEEFCE0E9D1E40DB@xxxxxxxxxxxxxxxxxxxxxxxxxxx> <9cde8bff05051819402d7b80e@xxxxxxxxxxxxxx>
Reply-to: Christian.Limpach@xxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On 5/19/05, aq <aquynh@xxxxxxxxx> wrote:
> > The script from python.org that Anthony posted seems to fit the bill.
> 
> no, that script doesnt work very well, because:
> 1. almost all the code indented by 4 spaces, but his script convert
> tab to 8 spaces
> 2. some code consider tab as 4 and 8 spaces in the same file, so it is
> hard to use this script.
> 3. that script doesnt see how python deal with the code. for example,
> lines the python code is aligned with the previous line, but the
> script doesnt take that into account. that is a problem.
> 
> a small example: file tools/python/xen/xm/main.py has few tabs inside,
> and here is how Anthony's script converts the code, and it does it
> wrongly. i have 3 files to compare here, so you can make a conclusion:
> the main.org.py (copy from original main.py), main-t2s.py (converted
> with Anthony's script, with tabsize=4) and main-aq.py (my script,
> coverted manually)
> 
> now to see the problem, here is a hunk taken from the diffs. see the
> commented i put next to the broken line:

That's because you broke the script by changing tabsize to 4.  As
Anthony wrote, the python manual describes the algorithm used to
expand tabs and how tabs get expanded has nothing to with how you have
indented your program.  Whether your indention levels are 4 character
wide or 8 doesn't matter, a tab always means go to the next 8
character column.  The original main.py looks visually incorrect at
the args.append line (it's indented by 8 characters instead of 4) but
that's not a bug.

> > I agree that getting rid of the tabs is important, but it can happen
> > after some of the outstanding tools merges get completed.
> 
> i think it is better to do it now, when there are not much code having
> problem. in the future, code get bigger, so it is more difficult to
> convert and check everything.

I'm not too keen on seeing this done in any of the 2.0 trees.

    christian

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel