[pyferret] 36/110: WIP: some python3 changes

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Jul 28 08:41:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository pyferret.

commit 9ec069827ed9cf19de577109f911b08e627a92d6
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Fri Oct 30 14:07:17 2015 +0000

    WIP: some python3 changes
---
 debian/patches/python3.patch | 314 +++++++++++++++++++++++++++++++++++++++++++
 debian/patches/series        |   1 +
 2 files changed, 315 insertions(+)

diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
new file mode 100644
index 0000000..d17d0b2
--- /dev/null
+++ b/debian/patches/python3.patch
@@ -0,0 +1,314 @@
+Author: Alastair McKinstry <mckinstry at debian.org>
+Description: Python3 support for pyferret (INCOMPLETE)
+Last-Updated: 2015-10-30
+Forwarded: no
+
+Index: pyferret-1.1.0/ferretmagic.py
+===================================================================
+--- pyferret-1.1.0.orig/ferretmagic.py
++++ pyferret-1.1.0/ferretmagic.py
+@@ -48,6 +48,7 @@ Usage
+ #  https://cdcvs.fnal.gov/redmine/projects/ipython_ext/repository/revisions/master/raw/ipythonPexpect.py
+ #-----------------------------------------------------------------------------
+ 
++from __future__ import print_function
+ import os.path
+ import tempfile
+ import math
+@@ -422,8 +423,8 @@ class ferretMagics(Magics):
+     
+         self._shell.ferret_locked = True
+ 
+-        print 'WARNING: All future cell execution will be processed through pyferret!'
+-        print 'To return to IPython, issue %ferret_unlock'
++        print ('WARNING: All future cell execution will be processed through pyferret!')
++        print ('To return to IPython, issue %ferret_unlock')
+ 
+     @line_magic
+     def ferret_unlock(self, line):
+@@ -434,7 +435,7 @@ class ferretMagics(Magics):
+     
+         self._shell.ferret_locked = False
+     
+-        print 'Notebook will use IPython'
++        print ('Notebook will use IPython')
+ 
+ # Let's rewrite InteractiveShell.run_cell to do automatic processing with pyferret,
+ # if desired
+Index: pyferret-1.1.0/gcircle.py
+===================================================================
+--- pyferret-1.1.0.orig/gcircle.py
++++ pyferret-1.1.0/gcircle.py
+@@ -4,9 +4,11 @@ Module of functions involving great circ
+ with points given in longitudes and latitudes.
+ """
+ 
++from __future__ import print_function
+ import math
+ import numpy
+ import numpy.random
++from past.builtins import xrange
+ 
+ # Equitorial radius of the earth in kilometers
+ EARTH_ER = 6378.137
+@@ -384,15 +386,15 @@ if __name__ == "__main__":
+     dists = lonlatdistance(0.0, 0.0, tenten, 0.0)
+     if not numpy.allclose(dists, tenten):
+         raise ValueError("Equatorial distances FAIL; expect: %s; found: %s" % (str(tenten), str(dists)))
+-    print "Equatorial distance: PASS"
+-    print
++    print ("Equatorial distance: PASS")
++    print ()
+ 
+     # On any meridian, distance = delta latitude
+     dists = lonlatdistance(20.0, 0.0, 20.0, tenten)
+     if not numpy.allclose(dists, tenten):
+         raise ValueError("Meridional distances FAIL; expect: %s; found: %s" % (str(tenten), str(dists)))
+-    print "Meridional distance: PASS"
+-    print
++    print ("Meridional distance: PASS")
++    print ()
+ 
+     # Play with some distances between cities (deg W, deg N)
+     seattle =  (122.0 + (20.0 / 60.0), 47.0 + (37.0 / 60.0))
+@@ -415,8 +417,8 @@ if __name__ == "__main__":
+         raise ValueError("Seattle, Portland, Spokane distance matrix in miles\n" \
+                          "    expect: %s\n"
+                          "    found:  %s" % (str(expected), str(dists)))
+-    print "Seattle, Portland, Spokane distance matrix: PASS"
+-    print
++    print ("Seattle, Portland, Spokane distance matrix: PASS")
++    print ()
+ 
+     lons = ( austin[0], houston[0], dallas[0] )
+     lons1, lons2 = numpy.meshgrid(lons, lons)
+@@ -431,8 +433,8 @@ if __name__ == "__main__":
+         raise ValueError("Austin, Houston, Dallas distance matrix in miles\n" \
+                          "    expect: %s\n"
+                          "    found:  %s" % (str(expected), str(dists)))
+-    print "Austin, Houston, Dallas distance matrix: PASS"
+-    print
++    print ("Austin, Houston, Dallas distance matrix: PASS")
++    print ()
+ 
+     # Test lonlatintersect
+     # Intersections of the equator with meridians
+@@ -469,8 +471,8 @@ if __name__ == "__main__":
+     if not numpy.allclose(pt2lats[1:-1], 0.0):
+         raise ValueError("Valid pt2lats: expect: all zeros, found %s" %\
+                           str(pt2lats[1:-1]))
+-    print "Equator/meridian intersections: PASS"
+-    print
++    print ("Equator/meridian intersections: PASS")
++    print ()
+ 
+     ((pt1lons, pt1lats), (pt2lons, pt2lats)) = \
+             lonlatintersect( 0.0, 89.99, 180.0, 89.99,
+@@ -482,8 +484,8 @@ if __name__ == "__main__":
+                          (str([45.0, 90.0, 135.0, -90.0]),
+                           str([float(pt1lons), float(pt1lats),
+                                float(pt2lons), float(pt2lats)])))
+-    print "Mini north pole cross intersections: PASS"
+-    print
++    print ("Mini north pole cross intersections: PASS")
++    print ()
+ 
+ 
+     # Test lonlatfwdpt
+@@ -491,15 +493,15 @@ if __name__ == "__main__":
+     if not ( numpy.allclose(lons, portland[0]) and numpy.allclose(lats, portland[1]) ):
+         raise ValueError("Zero forward from portland to spokane: expect %s, found %s" % \
+                          (str(portland), str((lons, lats))))
+-    print "Zero forward: PASS"
+-    print
++    print ("Zero forward: PASS")
++    print ()
+ 
+     lons, lats = lonlatfwdpt(portland[0], portland[1], spokane[0], spokane[1], 1.0)
+     if not ( numpy.allclose(lons, spokane[0]) and numpy.allclose(lats, spokane[1]) ):
+         raise ValueError("One forward from portland to spokane: expect %s, found %s" % \
+                          (str(spokane), str((lons, lats))))
+-    print "One forward: PASS"
+-    print
++    print ("One forward: PASS")
++    print ()
+ 
+     lons, lats = lonlatfwdpt(0.0, 0.0, tenten, 0.0, 3.0)
+     expectlons = 3.0 * tenten
+@@ -520,8 +522,8 @@ if __name__ == "__main__":
+     if not numpy.allclose(lats[1:], 0.0):
+         raise ValueError("Valid fwd equator lats: expect: all zeros, found: %s" %\
+                           str(lats[1:]))
+-    print "Fwd equator: PASS"
+-    print
++    print ("Fwd equator: PASS")
++    print ()
+ 
+     lons, lats = lonlatfwdpt(0.0, -90.0, 0.0, tenten, 2.0)
+     # First longitude could be anything, but this algorithm gives 0.0
+@@ -546,8 +548,8 @@ if __name__ == "__main__":
+     if not numpy.allclose(lats[:-1], expectlats[:-1]):
+         raise ValueError("Valid fwd prime meridian lats: expect: %s, found: %s" %\
+                           (str(expectlats[:-1]), str(lats[:-1])))
+-    print "Fwd prime meridian: PASS"
+-    print
++    print ("Fwd prime meridian: PASS")
++    print ()
+ 
+     lons, lats = lonlatfwdpt(0.0, 0.0, 45.0, 45.0, (2.0, 3.0, 4.0, 5.0))
+     expectlons = [ 135.0, 180.0, -135.0, -45.0 ]
+@@ -558,8 +560,8 @@ if __name__ == "__main__":
+     if not numpy.allclose(lats, expectlats):
+         raise ValueError("Fwd diagonal lats: expect: %s, found: %s" %\
+                           (str(expectlats), str(lats)))
+-    print "Fwd diagonal: PASS"
+-    print
++    print ("Fwd diagonal: PASS")
++    print ()
+ 
+     # Test equdistscatter
+     lons, lats = equidistscatter(0.0, 0.0, 0.0, 0.0, 1.0)
+@@ -568,8 +570,8 @@ if __name__ == "__main__":
+         raise ValueError("Equidistscatter single-point FAIL; \n" \
+                          "  expect: ([0.0],[0.0]), \n" \
+                          "  found (%s,%s)" % (str(lons), str(lats)))
+-    print "Equidistscatter single-point PASS"
+-    print
++    print ("Equidistscatter single-point PASS")
++    print ()
+ 
+     lons, lats = equidistscatter(0.0, 90.0, 90.0, 90.0, 1.0)
+     if (lons.shape != (1,)) or (lons[0] != 45.0) or \
+@@ -577,8 +579,8 @@ if __name__ == "__main__":
+         raise ValueError("Equidistscatter pole-point FAIL; \n" \
+                          "  expect: ([45.0],[90.0]), \n" \
+                          "  found (%s,%s)" % (str(lons), str(lats)))
+-    print "Equidistscatter pole-point PASS"
+-    print
++    print ("Equidistscatter pole-point PASS")
++    print ()
+ 
+     lons, lats = equidistscatter(0.0, 0.0, 90.0, 0.0, 1.0)
+     if not numpy.all( lats == 0.0 ):
+@@ -594,8 +596,8 @@ if __name__ == "__main__":
+         raise ValueError("Equidistscatter equitorial FAIL; \n" \
+                          "  expect: longitudes monotonic increasing by less than 1.0001 degrees, \n" \
+                          "  found %s" % str(lons))
+-    print "Equidistscatter equitorial PASS"
+-    print
++    print ("Equidistscatter equitorial PASS")
++    print ()
+ 
+     lons, lats = equidistscatter(0.0, 0.0, 0.0, 90.0, 1.0)
+     if not numpy.all( lons == 0.0 ):
+@@ -611,8 +613,8 @@ if __name__ == "__main__":
+         raise ValueError("Equidistscatter meridional FAIL; \n" \
+                          "  expect: latitudes monotonic increasing by less than 1.0001 degrees, \n" \
+                          "  found %s" % str(lats))
+-    print "Equidistscatter meridional PASS"
+-    print
++    print ("Equidistscatter meridional PASS")
++    print ()
+ 
+     lons, lats = equidistscatter(0.0, 0.0, 90.0, 90.0, 5.0, 15.0)
+     nndists = [ ]
+@@ -629,9 +631,9 @@ if __name__ == "__main__":
+         raise ValueError("Equidistscatter region FAIL; \n" \
+                          "  expect nearest neighbor distances < 10.0, \n" \
+                          "  found %s" % str(nndists))
+-    print "Nearest neighbor distances: \n" \
++    print ("Nearest neighbor distances: \n" \
+           "    min = %f, max = %f, mean = %f, stdev = %f" % \
+-          (nndists.min(), nndists.max(), nndists.mean(), nndists.std())
++          (nndists.min(), nndists.max(), nndists.mean(), nndists.std()))
+ 
+-    print "Equidistscatter region PASS"
+-    print
++    print ("Equidistscatter region PASS")
++    print ()
+Index: pyferret-1.1.0/pyfermod/filenamecompleter.py
+===================================================================
+--- pyferret-1.1.0.orig/pyfermod/filenamecompleter.py
++++ pyferret-1.1.0/pyfermod/filenamecompleter.py
+@@ -9,6 +9,7 @@ be names of existing files that match th
+ directory/file name.
+ """
+ 
++from __future__ import print_function
+ import os.path
+ 
+ class FilenameCompleter(object):
+@@ -116,12 +117,12 @@ if __name__ == '__main__':
+     # Test an empty string
+     actdirlist = os.listdir(os.curdir)
+     actdirlist.sort()
+-    print 'Contents of current directory'
++    print ('Contents of current directory')
+     cmpdirlist = []
+     k = 0
+     fnam = completer.complete('', 0)
+     while fnam != None:
+-        print '    %s' % fnam
++        print ('    %s' % fnam)
+         cmpdirlist.append(fnam)
+         k += 1
+         fnam = completer.complete('', k)
+@@ -131,26 +132,26 @@ if __name__ == '__main__':
+ 
+     # Test with a tilde string
+     tildedir = '~' + os.sep
+-    print ''
+-    print 'Contents of %s' % tildedir
++    print ('')
++    print ('Contents of %s' % tildedir)
+     tildenames = []
+     k = 0
+     fnam = completer.complete(tildedir, 0)
+     while fnam != None:
+-        print '    %s' % fnam
++        print ('    %s' % fnam)
+         tildenames.append(fnam)
+         k += 1
+         fnam = completer.complete(tildedir, k)
+     
+     # Test with an environment variable
+     homedir = '$HOME' + os.sep
+-    print ''
+-    print 'Contents of %s' % homedir
++    print ('')
++    print ('Contents of %s' % homedir)
+     homenames = []
+     k = 0
+     fnam = completer.complete(homedir, 0)
+     while fnam != None:
+-        print '    %s' % fnam
++        print ('    %s' % fnam)
+         homenames.append(fnam)
+         k += 1
+         fnam = completer.complete(homedir, k)
+@@ -161,13 +162,13 @@ if __name__ == '__main__':
+ 
+     # Try with $HOME/bin/
+     bindir = '$HOME' + os.sep + 'bin' + os.sep
+-    print ''
+-    print 'Contents of %s' % bindir
++    print ('')
++    print ('Contents of %s' % bindir)
+     binnames = []
+     k = 0
+     fnam = completer.complete(bindir, 0)
+     while fnam != None:
+-        print '    %s' % fnam
++        print ('    %s' % fnam)
+         binnames.append(fnam)
+         k += 1
+         fnam = completer.complete(bindir, k)
+@@ -190,6 +191,6 @@ if __name__ == '__main__':
+                          (invalid_name, fnam))
+ 
+     # All tests successful
+-    print ''
+-    print 'Success'
++    print ('')
++    print ('Success')
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 2395bce..687cd30 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 set-envvars.patch
 automate-tests.parch
+python3.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyferret.git



More information about the debian-science-commits mailing list