Note the childs to children changes in Bio/Phylo/Consensus.py
included fixing internal variable names only.
Not applying all the catergories ==> categories fixes
to the (deprecated) EMBOSS wrappers as some would be
functional changes.
Also no more LaTeX files (for spell checking)
Reverted unwanted changes (mostly arrays in tests, but also
some whitespace in doctests).
Remaining changes are standardising spacing between module
docstring and imports, and lower-case \x<hex> in strings.
EMBOSS 6.1.0 was released over ten years ago
(15th July 2009), so there is little reason
to preserve the long obsolete command line
argument variants.
Also, this similified fixing the triple-quoted
string indentation - see #2369.
D413 Missing blank line after last section
D412 No blank lines allowed between a section header and its content
(Seems adopting numpydoc naming means the flake8 plugin now
is stricter about section formatting and/or the machine I
did the previous commits on had an out of date flake plugin?)
$ pep8 --select E121 Bio/Emboss/Applications.py
$ pep8 Bio/Emboss/Applications.py
Bio/Emboss/Applications.py:131:80: E501 line too long (90 > 79 characters)
Bio/Emboss/Applications.py:141:80: E501 line too long (129 > 79 characters)
Bio/Emboss/Applications.py:145:80: E501 line too long (90 > 79 characters)
Bio/Emboss/Applications.py:151:80: E501 line too long (134 > 79 characters)
Bio/Emboss/Applications.py:176:80: E501 line too long (82 > 79 characters)
Bio/Emboss/Applications.py:211:80: E501 line too long (83 > 79 characters)
Bio/Emboss/Applications.py:268:80: E501 line too long (81 > 79 characters)
Bio/Emboss/Applications.py:424:80: E501 line too long (80 > 79 characters)
Bio/Emboss/Applications.py:448:80: E501 line too long (83 > 79 characters)
Bio/Emboss/Applications.py:475:80: E501 line too long (82 > 79 characters)
Bio/Emboss/Applications.py:541:80: E501 line too long (84 > 79 characters)
Bio/Emboss/Applications.py:773:80: E501 line too long (80 > 79 characters)
Bio/Emboss/Applications.py:891:80: E501 line too long (82 > 79 characters)
Bio/Emboss/Applications.py:997:80: E501 line too long (82 > 79 characters)
Bio/Emboss/Applications.py:1006:80: E501 line too long (82 > 79 characters)
Bio/Emboss/Applications.py:1199:80: E501 line too long (85 > 79 characters)
Bio/Emboss/Applications.py:1248:80: E501 line too long (87 > 79 characters)
Bio/Emboss/Applications.py:1253:80: E501 line too long (93 > 79 characters)
This was mostly due to the latest version of the pep8
tool being stricter and wanting the __docformat__ line
after the module level imports.
Rather than moving them all, I removed them - and we'll
switch to using reStructuredText as the default when
converting the docstrings into API HTML pages for the
website.
This commit also includes assorted other PEP8 fixes which
our recommend git pre-commit hook spotted, and I fixed by
hand.
This is currently redundant as we are carefully only
using this simple print style which is both a print
statement (with redundant brackets) under Python 2
and a print function under Python 3:
print(variable)
However, adding the __future__ import to any file using
a print should catch any accidental usage of the print
statement in the near future (even if not testing under
Python 3 where it would be spotted since we've turned
off the print fixer during the 2to3 conversion).
This was automated as follows:
<python>
MAGIC = "from __future__ import print_function"
import os
import sys
def should_mark(filename):
handle = open(filename, "rU")
lines = [line.strip() for line in handle if "print" in line]
handle.close()
if MAGIC in lines:
#print("%s is marked" % filename)
return False
if "print" in lines:
print("TODO - %s has a naked print" % filename)
sys.exit(1)
for line in lines:
if "print" not in line:
continue
#print(line)
line = line.strip(" #")
if line.startswith(">>>") or line.startswith("..."):
#doctest
line = line[3:].strip()
if line.startswith("print ") or line.startswith("print("):
return True
print("%s has no print statements" % filename)
return False
def mark_file(filename, marker=MAGIC):
with open(filename, "rU") as h:
lines = list(h.readlines())
with open(filename, "w") as h:
while (lines[0].startswith("#") or not lines[0].strip()):
h.write(lines.pop(0))
if lines[0].startswith('"""') or lines[0].startswith('r"""'):
# Module docstring
if lines[0].strip() == '"""':
print("Non-PEP8 module docstring in %s" % filename)
if lines[0].rstrip().endswith('"""') and lines[0].strip() != '"""':
# One liner
print("One line module docstring in %s" % filename)
h.write(lines.pop(0))
else:
h.write(lines.pop(0))
while not lines[0].strip().endswith('"""'):
h.write(lines.pop(0))
h.write(lines.pop(0))
while (lines[0].startswith("#") or not lines[0].strip()):
h.write(lines.pop(0))
h.write(marker + "\n\n")
h.write("".join(lines))
for dirpath, dirnames, filenames in os.walk("."):
if dirpath.startswith("./build/"):
continue
for f in filenames:
if not f.endswith(".py"):
continue
f = os.path.join(dirpath, f)
if should_mark(f):
print("Marking %s" % f)
mark_file(f)
</python>
Plus some manual tweaking to ensure the doctests still pass
(e.g. on Jython 2.7b1, see last commit).
import os
from lib2to3.main import main
for dirpath, dirnames, filenames in os.walk("."):
if dirpath.startswith("./build/") or dirpath.startwith("./.git/"):
continue
print("=" * len(dirpath))
print(dirpath)
print("=" *len(dirpath))
for f in filenames:
if not f.endswith(".py"):
continue
filename = os.path.join(dirpath, f)
with open(filename) as h:
data = h.read()
if "print " not in data:
continue
if "print(" in data:
continue
print(filename)
e = main("lib2to3.fixes", ["-d", filename, "-f", "print", "-w", "-n"])
if e != 0:
os.remove(filename)
raise RuntimeError("Error %i from 2to3 (doctests) on %s"
% (e, filename))