diff --git a/casacore/fitting/fitting.py b/casacore/fitting/fitting.py index a784fdc..b0ec1e0 100644 --- a/casacore/fitting/fitting.py +++ b/casacore/fitting/fitting.py @@ -1,3 +1,5 @@ +from __future__ import print_function + from ._fitting import fitting import numpy as NUM import six @@ -231,7 +233,7 @@ def addconstraint(self, x, y=0, fnct=None, fid=0): functional("hyper", len(x)).todict() self._fitids[fid]["constraint"][i]["x"] = [float(v) for v in x] self._fitids[fid]["constraint"][i]["y"] = float(y) - six.print_(self._fitids[fid]["constraint"]) + print(self._fitids[fid]["constraint"]) def fitpoly(self, n, x, y, sd=None, wt=1.0, fid=0): if self.set(n=n + 1, fid=fid): diff --git a/casacore/images/coordinates.py b/casacore/images/coordinates.py index 77cbb93..bddf13b 100644 --- a/casacore/images/coordinates.py +++ b/casacore/images/coordinates.py @@ -25,7 +25,7 @@ # # $Id$ -import six +from __future__ import print_function class coordinatesystem(object): @@ -66,7 +66,7 @@ def dict(self): return self._csys def summary(self): - six.print_(str(self)) + print(str(self)) def _get_coordinatenames(self): """Create ordered list of coordinate names diff --git a/casacore/images/image.py b/casacore/images/image.py index a85de27..ef4ce8d 100644 --- a/casacore/images/image.py +++ b/casacore/images/image.py @@ -23,13 +23,13 @@ # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA +from __future__ import print_function from six import string_types, integer_types from ._images import Image import numpy import numpy.ma as nma from casacore.images.coordinates import coordinatesystem -import six class image(Image): @@ -154,7 +154,7 @@ def __init__(self, imagename, axis=0, maskname="", images=(), values=None, [(image, '', imgs)], locals=cu.getlocals(3)) except: - six.print_("Probably could not import casacore.util") + print("Probably could not import casacore.util") pass Image.__init__(self, imagename, maskname, imgs) else: @@ -592,21 +592,21 @@ def view(self, tempname='/tmp/tempimage'): # Test if casaviewer can be found. # On OS-X 'which' always returns 0, so use test on top of it. if os.system('test -x `which casaviewer` > /dev/null 2>&1') == 0: - six.print_("Starting casaviewer in the background ...") + print("Starting casaviewer in the background ...") self.unlock() if self.ispersistent(): os.system('casaviewer ' + self.name() + ' &') elif len(tempname) > 0: - six.print_(" making a persistent copy in " + tempname) - six.print_(" which should be deleted after the viewer has ended") + print(" making a persistent copy in " + tempname) + print(" which should be deleted after the viewer has ended") self.saveas(tempname) os.system('casaviewer ' + tempname + ' &') else: - six.print_("Cannot view because the image is in memory only.") - six.print_("You can browse a persistent copy of the image like:") - six.print_(" t.view('/tmp/tempimage')") + print("Cannot view because the image is in memory only.") + print("You can browse a persistent copy of the image like:") + print(" t.view('/tmp/tempimage')") else: - six.print_("casaviewer cannot be found") + print("casaviewer cannot be found") def _adaptAxes(self, axes): # If axes is a single integer value, turn it into a list. diff --git a/casacore/measures/__init__.py b/casacore/measures/__init__.py index 762700e..b91a125 100755 --- a/casacore/measures/__init__.py +++ b/casacore/measures/__init__.py @@ -31,6 +31,8 @@ import casacore.quanta as dq import os +from six import string_types + if 'MEASURESDATA' in os.environ.keys(): if 'AIPSPATH' not in os.environ.keys(): os.environ['AIPSPATH'] = '%s dummy dummy' % os.environ['MEASURESDATA'] diff --git a/casacore/tables/msutil.py b/casacore/tables/msutil.py index 6c117d6..6d49908 100644 --- a/casacore/tables/msutil.py +++ b/casacore/tables/msutil.py @@ -23,9 +23,10 @@ # 520 Edgemont Road # Charlottesville, VA 22903-2475 USA # +from __future__ import print_function + from six import string_types import numpy as np -import six from casacore.tables.table import (table, taql, _required_ms_desc, _complete_ms_desc) @@ -94,23 +95,23 @@ def addImagingColumns(msname, ack=True): 'SPEC': {'DEFAULTTILESHAPE': [4, 32, 128]}} # Add the columns(if not existing). Use the description of the DATA column. if 'MODEL_DATA' in cnames: - six.print_("Column MODEL_DATA not added; it already exists") + print("Column MODEL_DATA not added; it already exists") else: dminfo['NAME'] = 'modeldata' cdesc['comment'] = 'The model data column' t.addcols(maketabdesc(makecoldesc('MODEL_DATA', cdesc)), dminfo) if ack: - six.print_("added column MODEL_DATA") + print("added column MODEL_DATA") if 'CORRECTED_DATA' in cnames: - six.print_("Column CORRECTED_DATA not added; it already exists") + print("Column CORRECTED_DATA not added; it already exists") else: dminfo['NAME'] = 'correcteddata' cdesc['comment'] = 'The corrected data column' t.addcols(maketabdesc(makecoldesc('CORRECTED_DATA', cdesc)), dminfo) if ack: - six.print_("'added column CORRECTED_DATA") + print("'added column CORRECTED_DATA") if 'IMAGING_WEIGHT' in cnames: - six.print_("Column IMAGING_WEIGHT not added; it already exists") + print("Column IMAGING_WEIGHT not added; it already exists") else: # Add IMAGING_WEIGHT which is 1-dim and has type float. # It needs a shape, otherwise the CASA imager complains. @@ -128,7 +129,7 @@ def addImagingColumns(msname, ack=True): dminfo['NAME'] = 'imagingweight' t.addcols(maketabdesc(cd), dminfo) if ack: - six.print_("added column IMAGING_WEIGHT") + print("added column IMAGING_WEIGHT") # Add or overwrite keyword CHANNEL_SELECTION. if 'CHANNEL_SELECTION' in t.colkeywordnames('MODEL_DATA'): t.removecolkeyword('MODEL_DATA', 'CHANNEL_SELECTION') @@ -139,7 +140,7 @@ def addImagingColumns(msname, ack=True): chans = [[0, nch] for nch in nchans] t.putcolkeyword('MODEL_DATA', 'CHANNEL_SELECTION', np.int32(chans)) if ack: - six.print_("defined keyword CHANNEL_SELECTION in column MODEL_DATA") + print("defined keyword CHANNEL_SELECTION in column MODEL_DATA") # Flush the table to make sure it is written. t.flush() @@ -408,7 +409,7 @@ def msregularize(msname, newname): ant2 = tsub.getcol('ANTENNA2') t2 = taql('select from $t1 where !any(ANTENNA1 == $ant1 &&' + ' ANTENNA2 == $ant2)') - six.print_(nmissing, t1.nrows(), tsub.nrows(), t2.nrows()) + print(nmissing, t1.nrows(), tsub.nrows(), t2.nrows()) if t2.nrows() != nmissing: raise ValueError("A time/band chunk behaves strangely") # If nothing added yet, create a new table. @@ -438,8 +439,8 @@ def msregularize(msname, newname): else: tcombs = t.query(offset=0) tcombs.rename(newname) - six.print_(newname, 'has been created; it references the original MS') + print(newname, 'has been created; it references the original MS') if nadded > 0: - six.print_(' and', newname + '_adds', 'containing', nadded, 'new rows') + print(' and', newname + '_adds', 'containing', nadded, 'new rows') else: - six.print_(' no rows needed to be added') + print(' no rows needed to be added') diff --git a/casacore/tables/table.py b/casacore/tables/table.py index 64a347d..189f0da 100755 --- a/casacore/tables/table.py +++ b/casacore/tables/table.py @@ -36,6 +36,8 @@ """ +from __future__ import print_function + from six import string_types from ._tables import (Table, _default_ms, @@ -352,11 +354,11 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True, Table.__init__(self, tabname, lockopt, endian, memtype, nrow, tabledesc, dminfo) if ack: - six.print_('Successful creation of', - lockopt['option'] + '-locked table', - tabname + ':', - self.ncols(), 'columns,', - self.nrows(), 'rows') + print('Successful creation of', + lockopt['option'] + '-locked table', + tabname + ':', + self.ncols(), 'columns,', + self.nrows(), 'rows') else: # Deal with existing tables. if not tabname: @@ -372,28 +374,28 @@ def __init__(self, tablename, tabledesc=False, nrow=0, readonly=True, if isinstance(tabname, string_types): Table.__init__(self, tabname, lockopt, opt) if ack: - six.print_('Successful', typstr, 'open of', - lockopt['option'] + '-locked table', - tabname + ':', - self.ncols(), 'columns,', - self.nrows(), 'rows') + print('Successful', typstr, 'open of', + lockopt['option'] + '-locked table', + tabname + ':', + self.ncols(), 'columns,', + self.nrows(), 'rows') elif isinstance(tabname[0], string_types): # Concatenate and open named tables. Table.__init__(self, tabname, concatsubtables, lockopt, opt) if ack: - six.print_('Successful', typstr, 'open of', - lockopt['option'] + - '-locked concatenated tables', - tabname, ':', self.ncols(), 'columns,', - self.nrows(), 'rows') + print('Successful', typstr, 'open of', + lockopt['option'] + + '-locked concatenated tables', + tabname, ':', self.ncols(), 'columns,', + self.nrows(), 'rows') else: # Concatenate already open tables. Table.__init__(self, tabname, concatsubtables, 0, 0, 0) if ack: - six.print_('Successful virtual concatenation of', - len(tabname), 'tables:', self.ncols(), - 'columns,', self.nrows(), 'rows') + print('Successful virtual concatenation of', + len(tabname), 'tables:', self.ncols(), + 'columns,', self.nrows(), 'rows') # Create a row object for this table. self._makerow() @@ -622,7 +624,7 @@ def toascii(self, asciifile, headerfile='', columnnames=(), sep=' ', msg = self._toascii(asciifile, headerfile, columnnames, sep, precision, usebrackets) if len(msg) > 0: - six.print_(msg) + print(msg) def rename(self, newtablename): """Rename the table. @@ -1618,23 +1620,23 @@ def summary(self, recurse=False): tables referenced by table keywords. """ - six.print_('Table summary:', self.name()) - six.print_('Shape:', self.ncols(), 'columns by', self.nrows(), 'rows') - six.print_('Info:', self.info()) + print('Table summary:', self.name()) + print('Shape:', self.ncols(), 'columns by', self.nrows(), 'rows') + print('Info:', self.info()) tkeys = self.getkeywords() if (len(tkeys) > 0): - six.print_('Table keywords:', tkeys) + print('Table keywords:', tkeys) columns = self.colnames() if (len(columns) > 0): - six.print_('Columns:', columns) + print('Columns:', columns) for column in columns: ckeys = self.getcolkeywords(column) if (len(ckeys) > 0): - six.print_(column, 'keywords:', ckeys) + print(column, 'keywords:', ckeys) if (recurse): for key, value in tkeys.items(): tabname = _remove_prefix(value) - six.print_('Summarizing subtable:', tabname) + print('Summarizing subtable:', tabname) lt = table(tabname) if (not lt.summary(recurse)): break @@ -1829,36 +1831,36 @@ def browse(self, wait=True, tempname="/tmp/seltable"): waitstr1 = " &" waitstr2 = "background ..." if self.iswritable(): - six.print_("Flushing data and starting casabrowser in the " + - waitstr2) + print("Flushing data and starting casabrowser in the " + + waitstr2) else: - six.print_("Starting casabrowser in the " + waitstr2) + print("Starting casabrowser in the " + waitstr2) self.flush() self.unlock() if os.system('test -e ' + self.name() + '/table.dat') == 0: os.system('casabrowser ' + self.name() + waitstr1) elif len(tempname) > 0: - six.print_(" making a persistent copy in table " + tempname) + print(" making a persistent copy in table " + tempname) self.copy(tempname) os.system('casabrowser ' + tempname + waitstr1) if wait: from casacore.tables import tabledelete - six.print_(" finished browsing") + print(" finished browsing") tabledelete(tempname) else: - six.print_(" after browsing use tabledelete('" + tempname + - "') to delete the copy") + print(" after browsing use tabledelete('" + tempname + + "') to delete the copy") else: - six.print_("Cannot browse because the table is in memory only") - six.print_("You can browse a (shallow) persistent copy " + - "of the table like: ") - six.print_(" t.browse(True, '/tmp/tab1')") + print("Cannot browse because the table is in memory only") + print("You can browse a (shallow) persistent copy " + + "of the table like: ") + print(" t.browse(True, '/tmp/tab1')") else: try: import wxPython except ImportError: - six.print_('casabrowser nor wxPython can be found') + print('casabrowser nor wxPython can be found') return from wxPython.wx import wxPySimpleApp import sys @@ -1915,34 +1917,34 @@ def view(self, wait=True, tempname="/tmp/seltable"): waitstr1 = " &" waitstr2 = "background ..." if self.iswritable(): - six.print_("Flushing data and starting casaviewer " + - "in the " + waitstr2) + print("Flushing data and starting casaviewer " + + "in the " + waitstr2) else: - six.print_("Starting casaviewer in the " + waitstr2) + print("Starting casaviewer in the " + waitstr2) self.flush() self.unlock() if os.system('test -e ' + self.name() + '/table.dat') == 0: os.system('casaviewer ' + self.name() + waitstr1) viewed = True elif len(tempname) > 0: - six.print_(" making a persistent copy in table " + - tempname) + print(" making a persistent copy in table " + + tempname) self.copy(tempname) os.system('casaviewer ' + tempname + waitstr1) viewed = True if wait: from casacore.tables import tabledelete - six.print_(" finished viewing") + print(" finished viewing") tabledelete(tempname) else: - six.print_(" after viewing use tabledelete('" + - tempname + "') to delete the copy") + print(" after viewing use tabledelete('" + + tempname + "') to delete the copy") else: - six.print_("Cannot browse because the table is " + - "in memory only.") - six.print_("You can browse a (shallow) persistent " + - "copy of the table like:") - six.print_(" t.view(True, '/tmp/tab1')") + print("Cannot browse because the table is " + + "in memory only.") + print("You can browse a (shallow) persistent " + + "copy of the table like:") + print(" t.view(True, '/tmp/tab1')") # Could not view the table, so browse it. if not viewed: self.browse(wait, tempname) diff --git a/casacore/tables/tableutil.py b/casacore/tables/tableutil.py index f5b697e..9ec24ed 100755 --- a/casacore/tables/tableutil.py +++ b/casacore/tables/tableutil.py @@ -24,6 +24,7 @@ # Charlottesville, VA 22903-2475 USA # +from __future__ import print_function from collections import defaultdict @@ -233,7 +234,7 @@ def tablefromascii(tablename, asciifile, tab = table(asciifile, headerfile, tablename, autoheader, autoshape, sep, commentmarker, firstline, lastline, _columnnames=columnnames, _datatypes=datatypes, _oper=1) - six.print_('Input format: [' + tab._getasciiformat() + ']') + print('Input format: [' + tab._getasciiformat() + ']') # Close table and reopen it in correct way. tab = 0 return table(tablename, readonly=readonly, lockoptions=lockoptions, @@ -647,12 +648,12 @@ def tabledelete(tablename, checksubtables=False, ack=True): tabname = _remove_prefix(tablename) t = table(tabname, ack=False) if t.ismultiused(checksubtables): - six.print_('Table', tabname, 'cannot be deleted; it is still in use') + print('Table', tabname, 'cannot be deleted; it is still in use') else: t = 0 table(tabname, readonly=False, _delete=True, ack=False) if ack: - six.print_('Table', tabname, 'has been deleted') + print('Table', tabname, 'has been deleted') def tableexists(tablename): @@ -731,4 +732,4 @@ def tablestructure(tablename, dataman=True, column=True, subtable=False, """ t = table(tablename, ack=False) - six.print_(t.showstructure(dataman, column, subtable, sort)) + print(t.showstructure(dataman, column, subtable, sort)) diff --git a/casacore/tables/wxtablebrowser.py b/casacore/tables/wxtablebrowser.py index 8bd2d27..1583ae0 100755 --- a/casacore/tables/wxtablebrowser.py +++ b/casacore/tables/wxtablebrowser.py @@ -1,8 +1,8 @@ +from __future__ import print_function + from wxPython.grid import * from wxPython.wx import * -import six - class wxCasaTable(wxPyGridTableBase): """ @@ -73,7 +73,7 @@ def __init__(self, parent, log, ctable): EVT_GRID_CELL_RIGHT_CLICK(self, self.OnRightDown) # added def OnRightDown(self, event): # added - six.print_(self.GetSelectedRows()) # added + print(self.GetSelectedRows()) # added # ---------------------------------------------------------------------------