Py3 - Script to eliminate compatibility warnings.

Pulkit Goyal 7895pulkit at gmail.com
Sun Feb 21 22:06:15 UTC 2016


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")

Since I am new to community and still understanding how it works, I don't
know how to send patches. So i will be needing a bit of help on it for
future. Moreover I want to take part in GSOC-16 and work with everyone out
there. Any sort of guidelines are welcomed.

Thanks in advance.

Regards
Pulkit Goyal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160222/66730405/attachment.html>


More information about the Mercurial-devel mailing list