Py3 - Script to eliminate compatibility warnings.
Matt Mackall
mpm at selenic.com
Sun Feb 21 22:53:06 UTC 2016
On Mon, 2016-02-22 at 03:36 +0530, Pulkit Goyal wrote:
> Hello everyone,
>
> I am new here and I was working on a project which was listed in ideas of
> GSOC-16 named Moving towards Python 3.
> The first to-do was to eliminate the
> compatibility warnings. I wrote the following piece of python code which
> will automatically add the absolute_import to all the files where it is
> required.
>
> import re
> def line_prepender(filename, line):
> with open(filename, 'r+') as f:
> content = f.read()
> f.seek(0, 0)
> f.write(line.rstrip('\r\n') + '\n' + content)
> f=open("tests/test-check-py3-compat.t")
> for line in f:
> if(re.search(".*absolute_import",line)):
> fn=re.findall(".*?([a-z/.].*py).*",line)
> l=line_prepender(''.join(fn),"from __future__ import
> absolute_import")
So you've discovered that there's a test, and you've discovered that it's only
been partially done so far. Now you need to ask yourself: why did someone only
do half the work if finishing it was as easy as the above? Maybe that means it's
not that easy?
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list