Changeset 2829


Ignore:
Timestamp:
05/01/12 10:50:32 (2 years ago)
Author:
wehart
Message:

Portability 3.x fixes

Location:
pyutilib.excel/trunk/pyutilib/excel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pyutilib.excel/trunk/pyutilib/excel/excel.py

    r2336 r2829  
    2222except ImportError: 
    2323    pass 
     24try: 
     25    unicode 
     26except: 
     27    def unicode(x): 
     28        return x 
    2429 
    2530class ExcelDocument(object): 
     
    109114        """ 
    110115        recordset = win32com.client.Dispatch('ADODB.Recordset') 
    111         recordset.Open(u'SELECT * FROM [%s]'%self.name, self.document.connection, 0, 1) 
     116        recordset.Open(unicode('SELECT * FROM [%s]'%self.name), self.document.connection, 0, 1) 
    112117        try: 
    113118            return [self.encoding(field.Name) for field in recordset.Fields] 
     
    128133        recordset = win32com.client.Dispatch('ADODB.Recordset') 
    129134        if self.order_by: 
    130             recordset.Open(u'SELECT * FROM [%s] ORDER BY %s'%(self.name, self.order_by), self.document.connection, 0, 1) 
     135            recordset.Open(unicode('SELECT * FROM [%s] ORDER BY %s'%(self.name, self.order_by)), self.document.connection, 0, 1) 
    131136        else: 
    132             recordset.Open(u'SELECT * FROM [%s]'%self.name, self.document.connection, 0, 1) 
     137            recordset.Open(unicode('SELECT * FROM [%s]'%self.name), self.document.connection, 0, 1) 
    133138        try: 
    134139            while not recordset.EOF: 
     
    159164        recordset = win32com.client.Dispatch('ADODB.Recordset') 
    160165        if self.order_by: 
    161             recordset.Open(u'SELECT * FROM [%s] ORDER BY %s'%(self.name, self.order_by), self.document.connection, 0, 1) 
     166            recordset.Open(unicode('SELECT * FROM [%s] ORDER BY %s'%(self.name, self.order_by)), self.document.connection, 0, 1) 
    162167        else: 
    163             recordset.Open(u'SELECT * FROM [%s]'%self.name, self.document.connection, 0, 1) 
     168            recordset.Open(unicode('SELECT * FROM [%s]'%self.name), self.document.connection, 0, 1) 
    164169        try: 
    165170            fields = [self.encoding(field.Name) for field in recordset.Fields] 
  • pyutilib.excel/trunk/pyutilib/excel/spreadsheet.py

    r2336 r2829  
    5151        self.xl=None 
    5252        if _win32com is False: #pragma:nocover 
    53             raise pyutilib.common.ApplicationError, "Cannot dispatch Excel without win32com" 
     53            raise pyutilib.common.ApplicationError("Cannot dispatch Excel without win32com") 
    5454        self.xlsfile=None 
    5555        if filename is not None: 
     
    116116            return self.xl.Iteration 
    117117        if not type(val) is bool: 
    118             raise ValueError, "ExcelSpreadsheet calc_iterations can only be set to a boolean" 
     118            raise ValueError("ExcelSpreadsheet calc_iterations can only be set to a boolean") 
    119119        self.xl.Iteration = val 
    120120 
     
    123123            return self.xl.MaxIterations 
    124124        if (not type(val) in [int,float,long]) or val < 0: 
    125             raise ValueError, "ExcelSpreadsheet max_iterations can only be set to nonnegative integer" 
     125            raise ValueError("ExcelSpreadsheet max_iterations can only be set to nonnegative integer") 
    126126        self.xl.MaxIterations = val 
    127127 
     
    148148            val=((val,),) 
    149149        if len(val) != self.get_range_nrows(rangename): 
    150             raise IOError, "Setting data with "+str(len(val))+" rows but range has "+str(self.get_range_nrows(rangename)) 
     150            raise IOError("Setting data with "+str(len(val))+" rows but range has "+str(self.get_range_nrows(rangename))) 
    151151        if type(val) is tuple: 
    152152            data = val 
     
    263263                return self.ws().Range(rangeid) 
    264264        except com_error: 
    265             raise IOError, "Unknown range name `"+str(rangeid)+"'" 
     265            raise IOError("Unknown range name `"+str(rangeid)+"'") 
    266266 
    267267    def _excel_dispatch(self): 
Note: See TracChangeset for help on using the changeset viewer.