21 Commits

Author SHA1 Message Date
1d09790db5 Apply black style to test_geo.py, version 19.10b0. 2020-05-26 13:02:58 +01:00
706b7505da Remove python2 checks from Test/ (#2496)
Addresses part of issue #2490
2020-01-07 10:30:35 +00:00
cd6b0ba754 Improve test coverage Bio.Geo (#2210) 2019-08-19 14:18:38 +01:00
1b9e569a7f Using tool unify to convert Tests/ to use double quotes
Using https://github.com/myint/unify for this:

$ unify --quote \" --in-place Tests/*.py Tests/*/*.py
2019-08-02 14:10:22 +01:00
68c49161c2 Replace print and compare by unittest geo (#2100)
* replace print and compare test by unittest

* fix for python3

* travis
2019-06-04 07:13:13 +09:00
8a64442960 D200 One-line docstring should fit on one line with quotes
Plus a few other mostly docstring related flake8 fixes.
2019-04-19 09:17:45 +01:00
82272b1f36 autopep8 E265 - Format block comments.
$ autopep8 --version
autopep8 1.0.4
$ autopep8 -r -i --select E265 ...
2014-10-27 14:27:12 +00:00
e555f19ebc Add missing licence headers (specific copyright still needed) 2013-09-30 15:49:30 +01:00
de12c5e08f Add: from __future__ import print_statement
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>
2013-09-09 21:17:13 +01:00
7378e8aa50 Partially migrated to print-function-like syntax
For now we only handle the 'print' statement with a single argument,
  i. e.:

      print ... -> print(...)

  Migration was performed using a 2to3 fixer class:

      from lib2to3 import fixer_base, patcomp
      from lib2to3.fixer_util import Name, Call

      parend_expr = patcomp.compile_pattern(
          """atom< '(' [atom|term|testlist_gexp|STRING|NAME] ')' >""")

      class FixSinglePrint(fixer_base.BaseFix):
          PATTERN = "print_stmt"
          BM_compatible = True

          def transform(self, node, results):
              assert results
              assert node.children[0] == Name(u"print")
              args = node.children[1:]
              if len(args) != 1 or parend_expr.match(args[0]):
                  # We only fix 'print' statements which have _exactly_ one
                  # non-parenthesized argument.
                  return

              l_args = [arg.clone() for arg in args]
              l_args[0].prefix = u""
              n_stmt = Call(Name(u"print"), l_args)
              n_stmt.prefix = node.prefix
              return n_stmt
2013-08-31 00:54:26 +04:00
ec279fd198 Remove EOF whitespace and add a missing EOF newline. 2013-08-13 08:15:13 +02:00
add526271d Close handles in test_geo.py 2013-04-08 15:57:07 +01:00
5192d13e01 Fix whitespace before and after operators (PEP8 E221 and E222).
Whitespace was left intact in places where it helps readability.
2012-12-04 09:02:37 +00:00
536cc0e988 Avoid multiple imports on one line.
Fixes PEP8 E401 multiple imports on one line
2012-12-03 19:52:19 +08:00
4576bea9a4 Remove excessive EOF blank lines (found with pep8 --select W391). 2012-12-03 11:06:43 +00:00
0543e25c85 Fix test_geo.py on Python 3, latin versus utf8 encoding issue with some symbols in GEO files 2010-07-26 18:14:20 +01:00
ed5c398728 Adding Tests/geo/soft_ex_affy_chp.txt. 2008-01-21 12:00:23 +00:00
80abd28126 Using the new code in Bio.Geo. 2007-09-12 05:38:05 +00:00
3586e1b6f5 Simplified this script. 2007-09-12 02:34:44 +00:00
8c170c0364 Also test the five new examples from the NCBI to document the 2005 file format changes. 2006-03-28 11:33:35 +00:00
0efaac54c6 test files in Feo format. 2002-05-15 22:13:08 +00:00