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


Groups > comp.lang.python > #74434

Re: python-aware wdiff?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'repository': 0.05; 'indicated': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:software': 0.09; 'python': 0.11; 'jan': 0.12; '2.7': 0.14; 'changes': 0.15; "'-'": 0.16; 'deletions': 0.16; 'differs': 0.16; 'insertions': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'roy': 0.16; 'skip:[ 60': 0.16; 'url:gnu': 0.16; 'subject:python': 0.16; 'files.': 0.16; 'url:)': 0.16; 'wrote:': 0.18; 'example': 0.22; 'header:User-Agent:1': 0.23; 'versions': 0.24; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'skip:m 30': 0.32; 'skip:s 30': 0.35; 'tool': 0.35; 'anybody': 0.35; 'but': 0.35; 'really': 0.36; 'shows': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'turn': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'show': 0.63; 'such': 0.63; 'more': 0.64; 'within': 0.65; 'smith': 0.68; 'url:info': 0.73; 'obvious': 0.74; '3.4': 0.84; 'received:fios.verizon.net': 0.84; 'skip:< 50': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: python-aware wdiff?
Date Mon, 14 Jul 2014 16:01:55 -0400
References <D72E3D69-9015-44C2-8374-CF6CD57F501D@panix.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-71-175-90-87.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <D72E3D69-9015-44C2-8374-CF6CD57F501D@panix.com>
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11807.1405368158.18130.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405368158 news.xs4all.nl 2972 [2001:888:2000:d::a6]:40119
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74434

Show key headers only | View raw


On 7/14/2014 11:12 AM, Roy Smith wrote:
> Does anybody know of a wdiff-like tool
> (http://www.gnu.org/software/wdiff/) which is aware of python syntax and
> can show token changes instead of word changes.  Wdiff is can turn
>
> -    if not metar.is
> <http://metar.is>_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
> +    if not info.is
> <http://info.is>_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
>
> into
>
>      if not
> [-metar.is_in_temp_range_f(situation.weather.low_temperature,-]
> {+info.is_in_temp_range_f(situation.weather.low_temperature,+}
> situation.weather.high_temperature):
>
> but what I really want is:
>
>      if not
> [-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature,
> situation.weather.high_temperature):
>
> which makes it more obvious that the change is just the one token.  Does
> such a tool exist?

The under-known difflib.differ shows within line differences.
Your example would look like:

-    if not metar.is_in_temp_range_f(...):
?           ^^^^^
+    if not info.is_in_temp_range_f
?           ^^^^

Deletions and insertions are indicated with '-' and '+'.
I use this routinely, when backporting patches, in a script that differs 
the 2.7 and 3.4 versions of repository files.

-- 
Terry Jan Reedy

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


Thread

Re: python-aware wdiff? Terry Reedy <tjreedy@udel.edu> - 2014-07-14 16:01 -0400

csiph-web