Changeset 3553 for pykota

Show
Ignore:
Timestamp:
11/16/10 00:00:40 (13 years ago)
Author:
jerome
Message:

When dumping datas in CSV, we now completely ignore I/O errors which are
often caused by things like "dumpykota --data history | head".

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/dumper.py

    r3533 r3553  
    242242    def dumpWithSeparator(self, separator, allentries) : 
    243243        """Dumps datas with a separator.""" 
    244         for entries in allentries : 
    245             for entry in entries : 
    246                 line = [] 
    247                 for value in entry : 
    248                     try : 
    249                         strvalue = '"%s"' % value.encode(self.charset, \ 
    250                                                          "replace").replace(separator, 
    251                                                                             "\\%s" % separator).replace('"', '\\"') 
    252                     except AttributeError : 
    253                         if value is None : 
    254                             strvalue = '"None"' # Double quotes around None to prevent spreadsheet from failing 
    255                         else : 
    256                             strvalue = str(value) 
    257                     line.append(strvalue) 
    258                 try : 
     244        try : 
     245            for entries in allentries : 
     246                for entry in entries : 
     247                    line = [] 
     248                    for value in entry : 
     249                        try : 
     250                            strvalue = '"%s"' % value.encode(self.charset, \ 
     251                                                             "replace").replace(separator, 
     252                                                                                "\\%s" % separator).replace('"', '\\"') 
     253                        except AttributeError : 
     254                            if value is None : 
     255                                strvalue = '"None"' # Double quotes around None to prevent spreadsheet from failing 
     256                            else : 
     257                                strvalue = str(value) 
     258                        line.append(strvalue) 
     259 
    259260                    self.outfile.write("%s\n" % separator.join(line)) 
    260                 except IOError, msg : 
    261                     self.printInfo("%s : %s" % (_("PyKota data dumper failed : I/O error"), msg), "error") 
    262                     return -1 
     261        except IOError, msg : 
     262            pass # We used to return an error, not really needed 
    263263        return 0 
    264264