Commit ca637fde authored by James Harle's avatar James Harle
Browse files

2to3 in gui

parent 67505f90
......@@ -199,7 +199,7 @@ class Mask(object):
mask_data[index] = self.data[index]
#connected components
label_mask, num_labels = ndimage.label(mask_data)
mean_values = ndimage.sum(np.ones(self.data.shape),label_mask,range(1, num_labels+1))
mean_values = ndimage.sum(np.ones(self.data.shape),label_mask,list(range(1, num_labels+1)))
max_area_mask = None
if mean_values.size != 0:
max_area_index = np.argmax(mean_values)+1
......@@ -228,7 +228,7 @@ class Mask(object):
label_mask, num_labels = ndimage.label(mask_data)
if num_labels == 0: #if mask is empty/clear
return
mean_values = ndimage.sum(np.ones(self.data.shape),label_mask,range(1, num_labels+1))
mean_values = ndimage.sum(np.ones(self.data.shape),label_mask,list(range(1, num_labels+1)))
max_area_mask = None
if mean_values.size != 0:
max_area_index = np.argmax(mean_values)+1
......
......@@ -11,7 +11,7 @@ import numpy as np
from .selection_editor import PolygonEditor, BoxEditor
import os.path
from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt
from nemo_bdy_mask import Mask
from .nemo_bdy_mask import Mask
import logging
from PyQt4.QtGui import QSizePolicy
from matplotlib.colors import Normalize
......@@ -126,7 +126,7 @@ class MatplotlibWidget(QtGui.QWidget):
x = np.arange(0, self.mask.lon.shape[0])
y = np.arange(0, self.mask.lon.shape[1])
x_vals, y_vals = np.meshgrid(y, x)
grid = zip(x_vals.ravel(), y_vals.ravel())
grid = list(zip(x_vals.ravel(), y_vals.ravel()))
self._drawing_tool.polygon.set_linewidth(1.0)
p_path = Path(self._drawing_tool.polygon.xy)
......@@ -146,7 +146,7 @@ class MatplotlibWidget(QtGui.QWidget):
x = np.arange(0, self.mask.lon.shape[0])
y = np.arange(0, self.mask.lon.shape[1])
x_vals, y_vals = np.meshgrid(y, x)
grid = zip(x_vals.ravel(), y_vals.ravel()) #check for the index
grid = list(zip(x_vals.ravel(), y_vals.ravel())) #check for the index
self._drawing_tool.polygon.set_linewidth(1.0)
p_path = Path(self._drawing_tool.polygon.xy)
......
......@@ -51,7 +51,7 @@ class NameListEditor(QtGui.QWidget):
text.setText(str(self.settings[setting]))
text.textChanged.connect(lambda value=setting,\
var_name=setting: self.label_changed(value, var_name))
if self.bool_settings.has_key(setting):
if setting in self.bool_settings:
chkbox = QtGui.QCheckBox(self)
chkbox.setChecked(self.bool_settings[setting])
chkbox.stateChanged.connect(lambda value=setting,\
......@@ -109,7 +109,7 @@ class NameListEditor(QtGui.QWidget):
def label_changed(self, value, name):
""" callback when the text is changed in the text box"""
self.new_settings[name] = unicode(value).encode('utf_8')
self.new_settings[name] = str(value).encode('utf_8')
def combo_index_changed(self, value, name):
""" callback when the True/False drop down for the settings which has boolean value
......@@ -153,7 +153,7 @@ class NameListEditor(QtGui.QWidget):
try:
self.mask_settings_update.emit(float(self.settings['mask_max_depth']), float(self.settings['mask_shelfbreak_dist']))
except KeyError:
print 'Set the mask setting mask_max_depth and mask_shelfbreak_dist'
print('Set the mask setting mask_max_depth and mask_shelfbreak_dist')
if self.bool_settings['mask_file']:
self.bathymetry_update.emit(self.settings['bathy'],self.settings['mask_file'])
......
......@@ -9,7 +9,7 @@ import xml.etree.ElementTree as ET
from PyQt4 import QtGui
from PyQt4 import QtCore
from PyQt4.QtCore import pyqtSlot
import nemo_ncml_tab_widget
from . import nemo_ncml_tab_widget
from thredds_crawler.crawl import Crawl
class Ncml_generator(QtGui.QDialog):
......@@ -30,7 +30,7 @@ class Ncml_generator(QtGui.QDialog):
self.baseFile = os.path.join(testpath,'base.ncml')
else:
self.baseFile = basefile
print 'ncml baseFile : ', str(self.baseFile)
print('ncml baseFile : ', str(self.baseFile))
self.filename = None # store the output file pointer
self.initUI()
......@@ -49,15 +49,15 @@ class Ncml_generator(QtGui.QDialog):
'''
top panel for output file
'''
top_outfile_label = QtGui.QLabel(unicode('Output filename').encode('utf-8'))
top_outfile_label = QtGui.QLabel(str('Output filename').encode('utf-8'))
self.top_outfile_name = QtGui.QLineEdit() #location is pre-defined
self.top_outfile_name.setToolTip(unicode('Define output file').encode('utf-8'))
self.top_outfile_name.setToolTip(str('Define output file').encode('utf-8'))
self.top_outfile_name.returnPressed.connect(self.get_fname_input)
top_outfile_button = QtGui.QPushButton(unicode('Select file').encode('utf-8'))
top_outfile_button = QtGui.QPushButton(str('Select file').encode('utf-8'))
top_outfile_button.clicked.connect(self.get_fname)
top_grpBox = QtGui.QGroupBox(unicode('Define output file').encode('utf-8'), None)
top_grpBox = QtGui.QGroupBox(str('Define output file').encode('utf-8'), None)
top_grid = QtGui.QGridLayout(top_grpBox)
top_grid.setVerticalSpacing(5)
top_grid.setHorizontalSpacing(10)
......@@ -69,22 +69,22 @@ class Ncml_generator(QtGui.QDialog):
middle panel for tab folder
'''
self.tabWidget = QtGui.QTabWidget()
self.tracer_tab = nemo_ncml_tab_widget.Ncml_tab(unicode("Tracer").encode('utf-8'))
self.tracer_tab = nemo_ncml_tab_widget.Ncml_tab(str("Tracer").encode('utf-8'))
self.tracer_tab.setEnabled(False)
self.dynamic_tab = nemo_ncml_tab_widget.Ncml_tab(unicode("Dynamics").encode('utf-8'))
self.dynamic_tab = nemo_ncml_tab_widget.Ncml_tab(str("Dynamics").encode('utf-8'))
self.dynamic_tab.setEnabled(False)
self.ice_tab = nemo_ncml_tab_widget.Ncml_tab(unicode("Ice").encode('utf-8'))
self.ice_tab = nemo_ncml_tab_widget.Ncml_tab(str("Ice").encode('utf-8'))
self.ice_tab.setEnabled(False)
self.ecosys_tab = nemo_ncml_tab_widget.Ncml_tab(unicode("Ecosystem").encode('utf-8'))
self.ecosys_tab = nemo_ncml_tab_widget.Ncml_tab(str("Ecosystem").encode('utf-8'))
self.ecosys_tab.setEnabled(False)
self.grid_tab = nemo_ncml_tab_widget.Ncml_tab(unicode("Grid").encode('utf-8'))
self.grid_tab = nemo_ncml_tab_widget.Ncml_tab(str("Grid").encode('utf-8'))
self.grid_tab.setEnabled(False)
self.tabWidget.addTab(self.tracer_tab, unicode("Tracer").encode('utf-8'))
self.tabWidget.addTab(self.dynamic_tab, unicode("Dynamics").encode('utf-8'))
self.tabWidget.addTab(self.ice_tab, unicode("Ice").encode('utf-8'))
self.tabWidget.addTab(self.ecosys_tab, unicode("Ecosystem").encode('utf-8')) # should be disabled
self.tabWidget.addTab(self.grid_tab, unicode("Grid").encode('utf-8')) # should be disabled
self.tabWidget.addTab(self.tracer_tab, str("Tracer").encode('utf-8'))
self.tabWidget.addTab(self.dynamic_tab, str("Dynamics").encode('utf-8'))
self.tabWidget.addTab(self.ice_tab, str("Ice").encode('utf-8'))
self.tabWidget.addTab(self.ecosys_tab, str("Ecosystem").encode('utf-8')) # should be disabled
self.tabWidget.addTab(self.grid_tab, str("Grid").encode('utf-8')) # should be disabled
self.tabWidget.setMovable(False)
# if self.tabWidget.widget(self.tabWidget.currentIndex()).isEnabled() is True:
......@@ -93,10 +93,10 @@ class Ncml_generator(QtGui.QDialog):
'''
button bar
'''
go_btn = QtGui.QPushButton(unicode('Generate').encode('utf-8'))
go_btn.setToolTip(unicode('Add all variable definitions before generating NcML file.').encode('utf-8'))
cancel_btn = QtGui.QPushButton(unicode('Cancel').encode('utf-8'))
enable_btn = QtGui.QPushButton(unicode('Enable Tab').encode('utf-8'))
go_btn = QtGui.QPushButton(str('Generate').encode('utf-8'))
go_btn.setToolTip(str('Add all variable definitions before generating NcML file.').encode('utf-8'))
cancel_btn = QtGui.QPushButton(str('Cancel').encode('utf-8'))
enable_btn = QtGui.QPushButton(str('Enable Tab').encode('utf-8'))
#layout button bar
btn_hBox = QtGui.QHBoxLayout(None)
btn_hBox.setMargin(5)
......@@ -120,7 +120,7 @@ class Ncml_generator(QtGui.QDialog):
#self.setLayout(grp_box)
self.setWindowIcon(QtGui.QIcon('/Users/jdha/anaconda/lib/python2.7/site-packages/pynemo-0.2-py2.7.egg/pynemo/gui/nemo_icon.png')) #doesn't work
self.setWindowTitle(unicode("PyNEMO NcML Generator").encode('utf-8'))
self.setWindowTitle(str("PyNEMO NcML Generator").encode('utf-8'))
self.resize(650,300)
#has to change the default focus to stop the output file QTextedit to trigger the widget in focus when enter is pressed. Not sure why this happens???
......@@ -155,9 +155,9 @@ class Ncml_generator(QtGui.QDialog):
@pyqtSlot()
def enable_btn_update(self, enable_btn):
if self.tabWidget.widget(self.tabWidget.currentIndex()).isEnabled() is True:
enable_btn.setText(unicode('Disable Tab').encode('utf-8'))
enable_btn.setText(str('Disable Tab').encode('utf-8'))
else:
enable_btn.setText(unicode('Enable Tab').encode('utf-8'))
enable_btn.setText(str('Enable Tab').encode('utf-8'))
'''
call back to handle the generate button pressed
'''
......@@ -167,10 +167,10 @@ class Ncml_generator(QtGui.QDialog):
#validate output file
if self.tabWidget.widget(self.tabWidget.currentIndex()).isEnabled() is True:
self.tabWidget.widget(self.tabWidget.currentIndex()).setEnabled(False)
enable_btn.setText(unicode('Enable Tab').encode('utf-8'))
enable_btn.setText(str('Enable Tab').encode('utf-8'))
else:
self.tabWidget.widget(self.tabWidget.currentIndex()).setEnabled(True)
enable_btn.setText(unicode('Disable Tab').encode('utf-8'))
enable_btn.setText(str('Disable Tab').encode('utf-8'))
'''
call back to handle the generate button pressed
......@@ -180,14 +180,14 @@ class Ncml_generator(QtGui.QDialog):
#validate output file
if self.filename is None or self.filename == "":
if self.top_outfile_name.text() is None or self.top_outfile_name.text() == "":
QtGui.QMessageBox.critical(self, unicode('Something is wrong').encode('utf-8'), unicode('No output file specified!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, str('Something is wrong').encode('utf-8'), str('No output file specified!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
return
else:
self.filename = self.top_outfile_name.text()
if(os.path.exists(os.path.dirname(str(self.filename)))) == False:
#if os.path.dirname(os.path.dirname(os.path.exists(os.path.normpath(str(self.filename))))) == False:
QtGui.QMessageBox.critical(self, unicode('Something is wrong').encode('utf-8'), unicode('Invalid output directory! Cannot generate file!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, str('Something is wrong').encode('utf-8'), str('Invalid output directory! Cannot generate file!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
#print 'invalid target directory! Cannot generate.'
return
......@@ -201,7 +201,7 @@ class Ncml_generator(QtGui.QDialog):
self.tracer_tab.vosaline.src != "" :
tabsList.extend([self.tracer_tab.votemper, self.tracer_tab.vosaline])
else:
QtGui.QMessageBox.information(self, unicode('Something is wrong').encode('utf-8'), unicode('Not all the variables under the tracer tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('Something is wrong').encode('utf-8'), str('Not all the variables under the tracer tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
if self.ice_tab.isEnabled() is True:
......@@ -210,7 +210,7 @@ class Ncml_generator(QtGui.QDialog):
self.ice_tab.isnowthi.src != "" :
tabsList.extend([self.ice_tab.iicethic, self.ice_tab.ileadfra, self.ice_tab.isnowthi])
else:
QtGui.QMessageBox.information(self, unicode('Something is wrong').encode('utf-8'), unicode('Not all the variables under the ice tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('Something is wrong').encode('utf-8'), str('Not all the variables under the ice tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
if self.dynamic_tab.isEnabled() is True:
if self.dynamic_tab.vozocrtx.src != "" and \
......@@ -218,7 +218,7 @@ class Ncml_generator(QtGui.QDialog):
self.dynamic_tab.sossheig.src != "" :
tabsList.extend([self.dynamic_tab.vozocrtx, self.dynamic_tab.vomecrty, self.dynamic_tab.sossheig])
else:
QtGui.QMessageBox.information(self, unicode('Something is wrong').encode('utf-8'), unicode('Not all the variables under the dynamics tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('Something is wrong').encode('utf-8'), str('Not all the variables under the dynamics tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
if self.grid_tab.isEnabled() is True:
if self.grid_tab.gdept.src != "" and \
......@@ -229,14 +229,14 @@ class Ncml_generator(QtGui.QDialog):
self.grid_tab.e3v.src != "" :
tabsList.extend([self.grid_tab.gdept, self.grid_tab.gdepw, self.grid_tab.mbathy, self.grid_tab.e3t, self.grid_tab.e3u, self.grid_tab.e3v])
else:
QtGui.QMessageBox.information(self, unicode('Something is wrong').encode('utf-8'), unicode('Not all the variables under the grid tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('Something is wrong').encode('utf-8'), str('Not all the variables under the grid tab have been defined!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
try:
self.generateNcML(tabsList) #go ahead and do it
except:
raise
QtGui.QMessageBox.information(self, unicode('Success.').encode('utf-8'), unicode('NcML file generated.').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('Success.').encode('utf-8'), str('NcML file generated.').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
'''
Function to generates the NcML text and write it to the user defined output file
......@@ -248,68 +248,68 @@ class Ncml_generator(QtGui.QDialog):
self.root = self.tree.getroot()
#create a netcdf element for each tab variable
for tab in tabsList:
netcdfE = ET.Element(ns+unicode('netcdf').encode('utf-8')) #src directory is converted to the correct format when added/
netcdfE = ET.Element(ns+str('netcdf').encode('utf-8')) #src directory is converted to the correct format when added/
if str(tab.src).startswith("http:") or str(tab.src).startswith("https:"):
#Its url so use thredds crawler to get the urls
urls = self.url_trawler(tab.src,str(tab.regex))
aggE = ET.Element(ns+unicode('aggregation').encode('utf-8'), name=unicode(str(tab.name)).encode('utf-8'), type=unicode('joinExisting').encode('utf-8'), dimName=unicode('time_counter').encode('utf-8')) #tab.name already encoded
aggE = ET.Element(ns+str('aggregation').encode('utf-8'), name=str(str(tab.name)).encode('utf-8'), type=str('joinExisting').encode('utf-8'), dimName=str('time_counter').encode('utf-8')) #tab.name already encoded
for nc_url in urls:
tcNetcdf = ET.Element(ns+unicode('netcdf').encode('utf-8'), location=unicode(str(nc_url)).encode('utf-8'))
tcNetcdf = ET.Element(ns+str('netcdf').encode('utf-8'), location=str(str(nc_url)).encode('utf-8'))
aggE.append(tcNetcdf)
netcdfE.append(aggE)
else:
scanE = ET.Element(ns+unicode('scan').encode('utf-8'), location=unicode(str(tab.src)).encode('utf-8'), regExp=unicode(str(tab.regex)).encode('utf-8'))
scanE = ET.Element(ns+str('scan').encode('utf-8'), location=str(str(tab.src)).encode('utf-8'), regExp=str(str(tab.regex)).encode('utf-8'))
if tab.subdirs == True:
scanE.set(unicode('subdirs').encode('utf-8'), unicode('true').encode('utf-8'))
aggE = ET.Element(ns+unicode('aggregation').encode('utf-8'), name=unicode(str(tab.name)).encode('utf-8'), type=unicode('joinExisting').encode('utf-8'), dimName=unicode('time_counter').encode('utf-8')) #tab.name already encoded
scanE.set(str('subdirs').encode('utf-8'), str('true').encode('utf-8'))
aggE = ET.Element(ns+str('aggregation').encode('utf-8'), name=str(str(tab.name)).encode('utf-8'), type=str('joinExisting').encode('utf-8'), dimName=str('time_counter').encode('utf-8')) #tab.name already encoded
aggE.append(scanE)
netcdfE.append(aggE)
self.root[0].append(netcdfE) #add the new netcdf element to the top aggregation
#deal with variable name change TODO put this into a loop?
if tab.old_name is not None and tab.old_name != "":
vname = unicode('variable').encode('utf-8')
vname = str('variable').encode('utf-8')
#v is None
if tab.name == unicode('temperature').encode('utf-8') and tab.old_name != unicode('votemper').encode('utf-8'):
if tab.name == str('temperature').encode('utf-8') and tab.old_name != str('votemper').encode('utf-8'):
v = ET.Element(ns+vname, name='votemper', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('salinity').encode('utf-8') and tab.old_name != unicode('vosaline').encode('utf-8'):
elif tab.name == str('salinity').encode('utf-8') and tab.old_name != str('vosaline').encode('utf-8'):
v = ET.Element(ns+vname, name='vosaline', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('ice_thickness').encode('utf-8') and tab.old_name != unicode('iicethic').encode('utf-8'):
elif tab.name == str('ice_thickness').encode('utf-8') and tab.old_name != str('iicethic').encode('utf-8'):
v = ET.Element(ns+vname, name='iicethic', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('leads_fraction').encode('utf-8') and tab.old_name != unicode('ileadfra').encode('utf-8'):
elif tab.name == str('leads_fraction').encode('utf-8') and tab.old_name != str('ileadfra').encode('utf-8'):
v = ET.Element(ns+vname, name='ileadfra', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('snow_thickness').encode('utf-8') and tab.old_name != unicode('isnowthi').encode('utf-8'):
elif tab.name == str('snow_thickness').encode('utf-8') and tab.old_name != str('isnowthi').encode('utf-8'):
v = ET.Element(ns+vname, name='isnowthi', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('zonal_velocity').encode('utf-8') and tab.old_name != unicode('vozocrtx').encode('utf-8'):
elif tab.name == str('zonal_velocity').encode('utf-8') and tab.old_name != str('vozocrtx').encode('utf-8'):
v = ET.Element(ns+vname, name='vozocrtx', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('meridian_velocity').encode('utf-8') and tab.old_name != unicode('vomecrty').encode('utf-8'):
elif tab.name == str('meridian_velocity').encode('utf-8') and tab.old_name != str('vomecrty').encode('utf-8'):
v = ET.Element(ns+vname, name='vomecrty', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('sea_surface_height').encode('utf-8') and tab.old_name != unicode('sossheig').encode('utf-8'):
elif tab.name == str('sea_surface_height').encode('utf-8') and tab.old_name != str('sossheig').encode('utf-8'):
v = ET.Element(ns+vname, name='sossheig', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('depth_at_t_points').encode('utf-8') and tab.old_name != unicode('gdept').encode('utf-8'):
elif tab.name == str('depth_at_t_points').encode('utf-8') and tab.old_name != str('gdept').encode('utf-8'):
v = ET.Element(ns+vname, name='gdept', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('depth_at_w_points').encode('utf-8') and tab.old_name != unicode('gdepw').encode('utf-8'):
elif tab.name == str('depth_at_w_points').encode('utf-8') and tab.old_name != str('gdepw').encode('utf-8'):
v = ET.Element(ns+vname, name='gdepw', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('number_of_wet_levels').encode('utf-8') and tab.old_name != unicode('mbathy').encode('utf-8'):
elif tab.name == str('number_of_wet_levels').encode('utf-8') and tab.old_name != str('mbathy').encode('utf-8'):
v = ET.Element(ns+vname, name='mbathy', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('vertical_scale_factors_at_t_points').encode('utf-8') and tab.old_name != unicode('e3t').encode('utf-8'):
elif tab.name == str('vertical_scale_factors_at_t_points').encode('utf-8') and tab.old_name != str('e3t').encode('utf-8'):
v = ET.Element(ns+vname, name='e3t', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('vertical_scale_factors_at_u_points').encode('utf-8') and tab.old_name != unicode('e3u').encode('utf-8'):
elif tab.name == str('vertical_scale_factors_at_u_points').encode('utf-8') and tab.old_name != str('e3u').encode('utf-8'):
v = ET.Element(ns+vname, name='e3u', orgName = str(tab.old_name))
self.root.append(v)
elif tab.name == unicode('vertical_scale_factors_at_v_points').encode('utf-8') and tab.old_name != unicode('e3v').encode('utf-8'):
elif tab.name == str('vertical_scale_factors_at_v_points').encode('utf-8') and tab.old_name != str('e3v').encode('utf-8'):
v = ET.Element(ns+vname, name='e3v', orgName = str(tab.old_name))
self.root.append(v)
......@@ -317,7 +317,8 @@ class Ncml_generator(QtGui.QDialog):
try:
self.indent(self.root, 0) #24Aug15 format the xml for pretty printing
self.tree.write(self.filename, encoding='utf-8')
except IOError as (errno, strerror):
except IOError as xxx_todo_changeme:
(errno, strerror) = xxx_todo_changeme.args
self.logger.error("I/O error({0}): {1}".format(errno, strerror))
except:
self.logger.error('Error generating ncml file')
......@@ -331,9 +332,9 @@ class Ncml_generator(QtGui.QDialog):
parser = ET.XMLParser(encoding="utf-8")
tree = ET.parse(self.baseFile, parser=parser)
return tree
except ET.ParseError, v:
except ET.ParseError as v:
row, column = v.position
print "error on row", row, "column", column, ":", v
print("error on row", row, "column", column, ":", v)
'''
Function to format xml. Based on code provided by http://effbot.org/zone/element-lib
......
......@@ -32,45 +32,45 @@ class Ncml_tab(QtGui.QWidget):
self.varStackedWidget = QtGui.QStackedWidget()
#variable chooser combobox
combo_vars = []
if(self.var == unicode("Tracer").encode('utf-8')):
combo_vars = [unicode('temperature').encode('utf-8'),unicode('salinity').encode('utf-8')] #votemper, vosaline
self.votemper = ncml_variable(unicode('temperature').encode('utf-8'),'votemper')
self.vosaline = ncml_variable(unicode('salinity').encode('utf-8'),'vosaline')
if(self.var == str("Tracer").encode('utf-8')):
combo_vars = [str('temperature').encode('utf-8'),str('salinity').encode('utf-8')] #votemper, vosaline
self.votemper = ncml_variable(str('temperature').encode('utf-8'),'votemper')
self.vosaline = ncml_variable(str('salinity').encode('utf-8'),'vosaline')
self.varStackedWidget.addWidget(self._addStackWidget("votemper"))
self.varStackedWidget.addWidget(self._addStackWidget("vosaline"))
#debug
# print 'Tracer has ' + str(self.varStackedWidget.count())
elif(self.var == unicode("Ice").encode('utf-8')):
combo_vars = [unicode('ice thickness').encode('utf-8'),unicode('leads fraction').encode('utf-8'),unicode('snow thickness').encode('utf-8')] #'iicethic,ileadfra,isnowthi
self.iicethic = ncml_variable(unicode('ice_thickness').encode('utf-8'),'iicethic')
self.ileadfra = ncml_variable(unicode('leads_fraction').encode('utf-8'),'ileadfra')
self.isnowthi = ncml_variable(unicode('snow_thickness').encode('utf-8'),'isnowthi')
elif(self.var == str("Ice").encode('utf-8')):
combo_vars = [str('ice thickness').encode('utf-8'),str('leads fraction').encode('utf-8'),str('snow thickness').encode('utf-8')] #'iicethic,ileadfra,isnowthi
self.iicethic = ncml_variable(str('ice_thickness').encode('utf-8'),'iicethic')
self.ileadfra = ncml_variable(str('leads_fraction').encode('utf-8'),'ileadfra')
self.isnowthi = ncml_variable(str('snow_thickness').encode('utf-8'),'isnowthi')
self.varStackedWidget.addWidget(self._addStackWidget("iicethic"))
self.varStackedWidget.addWidget(self._addStackWidget("ileadfra"))
self.varStackedWidget.addWidget(self._addStackWidget("isnowthi"))
# print 'Ice has ' + str(self.varStackedWidget.count())
elif(self.var == unicode("Dynamics").encode('utf-8')):
combo_vars = [unicode('zonal velocity').encode('utf-8'), unicode('meridian velocity').encode('utf-8'), unicode('sea surface height').encode('utf-8')] #vozocrtx, vomecrty, sossheig
self.vozocrtx = ncml_variable(unicode('zonal_velocity').encode('utf-8'),'vozocrtx')
self.vomecrty = ncml_variable(unicode('meridian_velocity').encode('utf-8'),'vomecrty')
self.sossheig = ncml_variable(unicode('sea_surface_height').encode('utf-8'),'sossheig')
elif(self.var == str("Dynamics").encode('utf-8')):
combo_vars = [str('zonal velocity').encode('utf-8'), str('meridian velocity').encode('utf-8'), str('sea surface height').encode('utf-8')] #vozocrtx, vomecrty, sossheig
self.vozocrtx = ncml_variable(str('zonal_velocity').encode('utf-8'),'vozocrtx')
self.vomecrty = ncml_variable(str('meridian_velocity').encode('utf-8'),'vomecrty')
self.sossheig = ncml_variable(str('sea_surface_height').encode('utf-8'),'sossheig')
self.varStackedWidget.addWidget(self._addStackWidget("vozocrtx"))
self.varStackedWidget.addWidget(self._addStackWidget("vomecrty"))
self.varStackedWidget.addWidget(self._addStackWidget("sossheig"))
# print 'Dynamics has ' + str(self.varStackedWidget.count())
elif(self.var == unicode("Grid").encode('utf-8')):
combo_vars = [unicode('depth at T points').encode('utf-8'),
unicode('depth at W points').encode('utf-8'),
unicode('number of wet levels').encode('utf-8'),
unicode('vertical scale factor at T points').encode('utf-8'),
unicode('vertical scale factor at U points').encode('utf-8'),
unicode('vertical scale factor at V points').encode('utf-8')] #gdept,gdepw,mbathy
self.gdept = ncml_variable(unicode('depth_at_t_points').encode('utf-8'),'gdept')
self.gdepw = ncml_variable(unicode('depth_at_w_points').encode('utf-8'),'gdepw')
self.mbathy = ncml_variable(unicode('number_of_wet_levels').encode('utf-8'),'mbathy')
self.e3t = ncml_variable(unicode('vertical_scale_factors_at_t_points').encode('utf-8'),'e3t')
self.e3u = ncml_variable(unicode('vertical_scale_factors_at_u_points').encode('utf-8'),'e3u')
self.e3v = ncml_variable(unicode('vertical_scale_factors_at_v_points').encode('utf-8'),'e3v')
elif(self.var == str("Grid").encode('utf-8')):
combo_vars = [str('depth at T points').encode('utf-8'),
str('depth at W points').encode('utf-8'),
str('number of wet levels').encode('utf-8'),
str('vertical scale factor at T points').encode('utf-8'),
str('vertical scale factor at U points').encode('utf-8'),
str('vertical scale factor at V points').encode('utf-8')] #gdept,gdepw,mbathy
self.gdept = ncml_variable(str('depth_at_t_points').encode('utf-8'),'gdept')
self.gdepw = ncml_variable(str('depth_at_w_points').encode('utf-8'),'gdepw')
self.mbathy = ncml_variable(str('number_of_wet_levels').encode('utf-8'),'mbathy')
self.e3t = ncml_variable(str('vertical_scale_factors_at_t_points').encode('utf-8'),'e3t')
self.e3u = ncml_variable(str('vertical_scale_factors_at_u_points').encode('utf-8'),'e3u')
self.e3v = ncml_variable(str('vertical_scale_factors_at_v_points').encode('utf-8'),'e3v')
self.varStackedWidget.addWidget(self._addStackWidget("gdept"))
self.varStackedWidget.addWidget(self._addStackWidget("gdepw"))
self.varStackedWidget.addWidget(self._addStackWidget("mbathy"))
......@@ -90,7 +90,7 @@ class Ncml_tab(QtGui.QWidget):
self.var_combo.currentIndexChanged.connect(lambda var_name = self.var : self.src_combo_changed(var_name))
self.var_combo.currentIndexChanged.connect(self.setWidgetStack)
#label
var_label = QtGui.QLabel(unicode('Variable').encode('utf-8'))
var_label = QtGui.QLabel(str('Variable').encode('utf-8'))
#set layout
stacked_hBox = QtGui.QHBoxLayout()
stacked_hBox.setMargin(5)
......@@ -115,11 +115,11 @@ class Ncml_tab(QtGui.QWidget):
button bar
'''
# reset button
reset_btn = QtGui.QPushButton(unicode('Reset').encode('utf-8'))
reset_btn.setToolTip(unicode('Reset fields to previously saved values').encode('utf-8'))
add_btn = QtGui.QPushButton(unicode('Add').encode('utf-8'))
reset_btn = QtGui.QPushButton(str('Reset').encode('utf-8'))
reset_btn.setToolTip(str('Reset fields to previously saved values').encode('utf-8'))
add_btn = QtGui.QPushButton(str('Add').encode('utf-8'))
add_btn.setDefault(True)
add_btn.setToolTip(unicode('Add the current definition to the NcML').encode('utf-8'))
add_btn.setToolTip(str('Add the current definition to the NcML').encode('utf-8'))
#connect up with events
reset_btn.clicked.connect(self.reset_tab)
add_btn.clicked.connect(self.add_tab)
......@@ -147,24 +147,24 @@ class Ncml_tab(QtGui.QWidget):
varLayout.setSpacing(20)
#labels
src_label = QtGui.QLabel(unicode('Source directory*').encode('utf-8'))
cbox_label = QtGui.QLabel(unicode('Includes subdirs').encode('utf-8'))
regex_label = QtGui.QLabel(unicode('Regular expression').encode('utf-8'))
old_name_label = QtGui.QLabel(unicode('Existing variable name*').encode('utf-8'))
src_label = QtGui.QLabel(str('Source directory*').encode('utf-8'))
cbox_label = QtGui.QLabel(str('Includes subdirs').encode('utf-8'))
regex_label = QtGui.QLabel(str('Regular expression').encode('utf-8'))
old_name_label = QtGui.QLabel(str('Existing variable name*').encode('utf-8'))
#input textboxs
self.varWidget.src_tedit = QtGui.QLineEdit() # input widgets need to be attached to the stacked widget itself
self.varWidget.src_tedit.setToolTip(unicode('either remote OPeNDAP server or local file absolute path').encode('utf-8'))
self.varWidget.src_tedit.setToolTip(str('either remote OPeNDAP server or local file absolute path').encode('utf-8'))
self.varWidget.src_tedit.returnPressed.connect(self.src_tedit_edited)
self.varWidget.cbox = QtGui.QCheckBox()
self.varWidget.cbox.setCheckable(True)
self.varWidget.cbox.setChecked(False)
self.varWidget.cbox.setToolTip(unicode('includes subdirectories').encode('utf-8'))
self.varWidget.cbox.setToolTip(str('includes subdirectories').encode('utf-8'))
self.varWidget.regex_tedit = QtGui.QLineEdit()
self.varWidget.regex_tedit.setToolTip(unicode('see http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ncml/AnnotatedSchema4.html#regexp').encode('utf-8'))
self.varWidget.regex_tedit.setToolTip(str('see http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/ncml/AnnotatedSchema4.html#regexp').encode('utf-8'))
self.varWidget.old_name_tedit = QtGui.QLineEdit()
self.varWidget.old_name_tedit.setToolTip(unicode('variable name in data file').encode('utf-8'))
self.varWidget.old_name_tedit.setToolTip(str('variable name in data file').encode('utf-8'))
self.varWidget.old_name_tedit.setText(old_name)
varLayout.addWidget(src_label, 1, 0, 1, 1)
......@@ -201,10 +201,10 @@ class Ncml_tab(QtGui.QWidget):
#validate the input now
if not str(src_tedit_input).startswith('http'):
if not os.path.isabs(src_tedit_input): #assumes local file
QtGui.QMessageBox.critical(self, unicode('Something is wrong').encode('utf-8'), unicode('source directory must be an absolute path!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, str('Something is wrong').encode('utf-8'), str('source directory must be an absolute path!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
self.varStackedWidget.currentWidget().src_tedit.clear()
if not os.path.exists(src_tedit_input) :
QtGui.QMessageBox.critical(self, unicode('Something is wrong').encode('utf-8'), unicode('source directory does not exist!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, str('Something is wrong').encode('utf-8'), str('source directory does not exist!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
self.varStackedWidget.currentWidget().src_tedit.clear()
'''
reset button pushed callback. The widgets are reset to default values
......@@ -213,34 +213,34 @@ class Ncml_tab(QtGui.QWidget):
def reset_tab(self):
#current screen value is not saved until the add button is pressed
#reset only reset the screen values, not the cached values
if self.var_combo.currentText() == unicode("temperature").encode('utf-8'):
if self.var_combo.currentText() == str("temperature").encode('utf-8'):
# print 'reset button is pushed, temperature ....'
self.resetValues(self.votemper)
elif self.var_combo.currentText() == unicode("salinity").encode('utf-8'):
elif self.var_combo.currentText() == str("salinity").encode('utf-8'):
self.resetValues(self.vosaline)
elif self.var_combo.currentText() == unicode("ice thickness").encode('utf-8'):
elif self.var_combo.currentText() == str("ice thickness").encode('utf-8'):
self.resetValues(self.iicethic)
elif self.var_combo.currentText() == unicode("leads fraction").encode('utf-8'):
elif self.var_combo.currentText() == str("leads fraction").encode('utf-8'):
self.resetValues(self.ileadfra)
elif self.var_combo.currentText() == unicode("snow thickness").encode('utf-8'):
elif self.var_combo.currentText() == str("snow thickness").encode('utf-8'):
self.resetValues(self.isnowthi)
elif self.var_combo.currentText() == unicode("zonal velocity").encode('utf-8'):
elif self.var_combo.currentText() == str("zonal velocity").encode('utf-8'):
self.resetValues(self.vozocrtx)
elif self.var_combo.currentText() == unicode("meridian velocity").encode('utf-8'):
elif self.var_combo.currentText() == str("meridian velocity").encode('utf-8'):
self.resetValues(self.vomecrty)
elif self.var_combo.currentText() == unicode("sea surface height").encode('utf-8'):
elif self.var_combo.currentText() == str("sea surface height").encode('utf-8'):
self.resetValues(self.sossheig)
elif self.var_combo.currentText() == unicode("depth at T points").encode('utf-8'):
elif self.var_combo.currentText() == str("depth at T points").encode('utf-8'):
self.resetValues(self.gdept)
elif self.var_combo.currentText() == unicode("depth at W points").encode('utf-8'):
elif self.var_combo.currentText() == str("depth at W points").encode('utf-8'):
self.resetValues(self.gdepw)
elif self.var_combo.currentText() == unicode("number of wet levels").encode('utf-8'):
elif self.var_combo.currentText() == str("number of wet levels").encode('utf-8'):
self.resetValues(self.mbathy)
elif self.var_combo.currentText() == unicode("vertical scale factor at T points").encode('utf-8'):
elif self.var_combo.currentText() == str("vertical scale factor at T points").encode('utf-8'):
self.resetValues(self.e3t)
elif self.var_combo.currentText() == unicode("vertical scale factor at U points").encode('utf-8'):
elif self.var_combo.currentText() == str("vertical scale factor at U points").encode('utf-8'):
self.resetValues(self.e3u)
elif self.var_combo.currentText() == unicode("vertical scale factor at V points").encode('utf-8'):
elif self.var_combo.currentText() == str("vertical scale factor at V points").encode('utf-8'):
self.resetValues(self.e3v)
'''
......@@ -270,7 +270,7 @@ class Ncml_tab(QtGui.QWidget):
#first validate the src tab is not null
if(self.varStackedWidget.currentWidget().src_tedit.text() is None or self.varStackedWidget.currentWidget().src_tedit.text() == '' or
self.varStackedWidget.currentWidget().old_name_tedit.text() is None or self.varStackedWidget.currentWidget().old_name_tedit.text() == ''):
QtGui.QMessageBox.critical(self, unicode('Something is wrong').encode('utf-8'), unicode('source directory and existing variable name cannot be blank!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.critical(self, str('Something is wrong').encode('utf-8'), str('source directory and existing variable name cannot be blank!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
'''
if not str(target).startsWith(unicode('http').encode('utf-8')):
......@@ -283,8 +283,8 @@ class Ncml_tab(QtGui.QWidget):
# be in the same directory.
if(self.var == unicode("Tracer").encode('utf-8')):
if (self.var_combo.currentText() == unicode("temperature").encode('utf-8')):
if(self.var == str("Tracer").encode('utf-8')):
if (self.var_combo.currentText() == str("temperature").encode('utf-8')):
if(self._sameValues(self.votemper)):
QtGui.QMessageBox.information(self, 'For information', 'No changes have been made!', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
......@@ -312,8 +312,8 @@ class Ncml_tab(QtGui.QWidget):
if self.vosaline.src == '':
self.vosaline.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.varStackedWidget.widget(1).src_tedit.setText(self.varStackedWidget.currentWidget().src_tedit.text())
elif(self.var == unicode('Ice').encode('utf-8')): #iicethic,ileadfra,isnowthi
if (self.var_combo.currentText() == unicode("ice thickness").encode('utf-8')):
elif(self.var == str('Ice').encode('utf-8')): #iicethic,ileadfra,isnowthi
if (self.var_combo.currentText() == str("ice thickness").encode('utf-8')):
if(self._sameValues(self.iicethic)):
QtGui.QMessageBox.information(self, 'For information', 'No changes have been made!', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
......@@ -324,9 +324,9 @@ class Ncml_tab(QtGui.QWidget):
self.iicethic.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.iicethic.regex = ''
elif(self.var_combo.currentText() == unicode("leads fraction").encode('utf-8')):
elif(self.var_combo.currentText() == str("leads fraction").encode('utf-8')):
if(self._sameValues(self.ileadfra)):
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.ileadfra.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.ileadfra.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -337,7 +337,7 @@ class Ncml_tab(QtGui.QWidget):
self.ileadfra.regex = ''
else:
if(self._sameValues(self.isnowthi)): #snow thickness
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.isnowthi.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.isnowthi.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -355,10 +355,10 @@ class Ncml_tab(QtGui.QWidget):
if self.isnowthi.src == '':
self.isnowthi.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.varStackedWidget.widget(2).src_tedit.setText(self.varStackedWidget.currentWidget().src_tedit.text())
elif(self.var == unicode("Dynamics").encode('utf-8')):
if (self.var_combo.currentText() == unicode("zonal velocity").encode('utf-8')):
elif(self.var == str("Dynamics").encode('utf-8')):
if (self.var_combo.currentText() == str("zonal velocity").encode('utf-8')):
if(self._sameValues(self.vozocrtx)):
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.vozocrtx.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.vozocrtx.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -367,7 +367,7 @@ class Ncml_tab(QtGui.QWidget):
self.vozocrtx.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.vozocrtx.regex = ''
elif(self.var_combo.currentText() == unicode('meridian velocity').encode('utf-8')):
elif(self.var_combo.currentText() == str('meridian velocity').encode('utf-8')):
if(self._sameValues(self.vomecrty)):
QtGui.QMessageBox.information(self, 'For information', 'No changes have been made!', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
......@@ -378,9 +378,9 @@ class Ncml_tab(QtGui.QWidget):
self.vomecrty.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.vomecrty.regex = ''
elif(self.var_combo.currentText() == unicode('sea surface height').encode('utf-8')):
elif(self.var_combo.currentText() == str('sea surface height').encode('utf-8')):
if(self._sameValues(self.sossheig)): #sea surface height
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.sossheig.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.sossheig.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -398,10 +398,10 @@ class Ncml_tab(QtGui.QWidget):
if self.sossheig.src == '':
self.sossheig.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.varStackedWidget.widget(2).src_tedit.setText(self.varStackedWidget.currentWidget().src_tedit.text())
elif(self.var == unicode("Grid").encode('utf-8')):
if (self.var_combo.currentText() == unicode("depth at T points").encode('utf-8')):
elif(self.var == str("Grid").encode('utf-8')):
if (self.var_combo.currentText() == str("depth at T points").encode('utf-8')):
if(self._sameValues(self.gdept)):
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.gdept.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.gdept.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -410,7 +410,7 @@ class Ncml_tab(QtGui.QWidget):
self.gdept.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.gdept.regex = ''
elif(self.var_combo.currentText() == unicode('depth at W points').encode('utf-8')):
elif(self.var_combo.currentText() == str('depth at W points').encode('utf-8')):
if(self._sameValues(self.gdepw)):
QtGui.QMessageBox.information(self, 'For information', 'No changes have been made!', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
......@@ -421,9 +421,9 @@ class Ncml_tab(QtGui.QWidget):
self.gdepw.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.gdepw.regex = ''
elif(self.var_combo.currentText() == unicode('number of wet levels').encode('utf-8')):
elif(self.var_combo.currentText() == str('number of wet levels').encode('utf-8')):
if(self._sameValues(self.mbathy)): #sea surface height
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.mbathy.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.mbathy.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -432,9 +432,9 @@ class Ncml_tab(QtGui.QWidget):
self.mbathy.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.mbathy.regex = ''
elif(self.var_combo.currentText() == unicode('vertical scale factor at T points').encode('utf-8')):
elif(self.var_combo.currentText() == str('vertical scale factor at T points').encode('utf-8')):
if(self._sameValues(self.e3t)): #sea surface height
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.e3t.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.e3t.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -443,9 +443,9 @@ class Ncml_tab(QtGui.QWidget):
self.e3t.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.e3t.regex = ''
elif(self.var_combo.currentText() == unicode('vertical scale factor at U points').encode('utf-8')):
elif(self.var_combo.currentText() == str('vertical scale factor at U points').encode('utf-8')):
if(self._sameValues(self.e3u)): #sea surface height
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.e3u.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.e3u.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -454,9 +454,9 @@ class Ncml_tab(QtGui.QWidget):
self.e3u.regex = self.varStackedWidget.currentWidget().regex_tedit.text()
else:
self.e3u.regex = ''
elif(self.var_combo.currentText() == unicode('vertical scale factor at V points').encode('utf-8')):
elif(self.var_combo.currentText() == str('vertical scale factor at V points').encode('utf-8')):
if(self._sameValues(self.e3v)): #sea surface height
QtGui.QMessageBox.information(self, unicode('For information').encode('utf-8'), unicode('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
QtGui.QMessageBox.information(self, str('For information').encode('utf-8'), str('No changes have been made!').encode('utf-8'), QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
else:
self.e3v.src = self._convertSrc(self.varStackedWidget.currentWidget().src_tedit.text())
self.e3v.subdirs = self.varStackedWidget.currentWidget().cbox.isChecked()
......@@ -497,10 +497,10 @@ class Ncml_tab(QtGui.QWidget):
elif fpath.startswith('file:/'):
temp = os.path.normpath(fpath[6:])
# print 'normal path : ', temp
target = unicode('file:/' + str(os.path.abspath(temp)).replace("\\", "/")).encode('utf-8')
target = str('file:/' + str(os.path.abspath(temp)).replace("\\", "/")).encode('utf-8')
else: #should be local file but not prefixed by file:/ we still check for absolute path
# print 'normal path : ', os.path.normpath(fpath)
target = unicode('file:/' + str(os.path.abspath(fpath)).replace("\\", "/")).encode('utf-8')
target = str('file:/' + str(os.path.abspath(fpath)).replace("\\", "/")).encode('utf-8')
# if not str(target).endswith('/'):
# target = target + '/'
......
......@@ -58,12 +58,12 @@ class PolygonEditor(object):
self.reset_line()
self.reset_polygon()
elif self.xy_values.shape[0] <= 2: # point or line for 1 or 2 points
xval, yval = zip(*self.xy_values)
xval, yval = list(zip(*self.xy_values))
if self.line == None:
self.line = Line2D(xval, yval, marker='o', markerfacecolor='r', animated=True)
self.axis.add_line(self.line)
else:
self.line.set_data(zip(*self.xy_values))
self.line.set_data(list(zip(*self.xy_values)))
self.reset_polygon()
else: # more than 2 points if polygon is not created then creates one and draws
if self.polygon == None:
......@@ -72,7 +72,7 @@ class PolygonEditor(object):
self.axis.add_patch(self.polygon)
else:
self.polygon.xy = self.xy_values
self.line.set_data(zip(*self.xy_values))
self.line.set_data(list(zip(*self.xy_values)))
self.draw_callback(None)
self.canvas.draw()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment