Changeset 4911


Ignore:
Timestamp:
27 Jan 2010, 21:11:21 (15 years ago)
Author:
uli
Message:

Use different logical and written headers for failed_writer. This
enables us to write different values to same-named (--IGNORE--)
columns.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/trunk/src/waeup/utils/batching.py

    r4901 r4911  
    239239        (base, ext) = os.path.splitext(path)
    240240        failed_path = os.path.join(temp_dir, "%s.pending%s" % (base, ext))
    241         failed_headers = [x for x in mapping.values()]
     241        failed_headers = mapping.keys()
    242242        failed_headers.append('--ERRORS--')
    243243        failed_writer = csv.DictWriter(open(failed_path, 'wb'),
    244244                                       failed_headers)
    245         failed_writer.writerow(dict([(x,x) for x in failed_headers]))
     245        first_row = mapping.items()
     246        first_row.append(("--ERRORS--", "--ERRORS--"),)
     247        failed_writer.writerow(dict(first_row))
    246248
    247249        finished_path = os.path.join(temp_dir, "%s.finished%s" % (base, ext))
     
    261263            if len(conv_warnings):
    262264                num_warns += 1
    263                 self.writeFailedRow(failed_writer, string_row, conv_warnings)
     265                self.writeFailedRow(failed_writer, raw_row, conv_warnings)
    264266                continue
    265267               
     
    268270                    num_warns += 1
    269271                    self.writeFailedRow(
    270                         failed_writer, string_row,
     272                        failed_writer, raw_row,
    271273                        "Not all parents do exist yet. Skipping")
    272274                    continue
     
    274276                    num_warns += 1
    275277                    self.writeFailedRow(
    276                         failed_writer, string_row,
     278                        failed_writer, raw_row,
    277279                        "This object already exists. Skipping.")
    278280                    continue
     
    285287                    num_warns += 1
    286288                    self.writeFailedRow(
    287                         failed_writer, string_row,
     289                        failed_writer, raw_row,
    288290                        "Cannot remove: no such entry.")
    289291                    continue
     
    294296                    num_warns += 1
    295297                    self.writeFailedRow(
    296                         failed_writer, string_row,
     298                        failed_writer, raw_row,
    297299                        "Cannot update: no such entry.")
    298300                    continue
Note: See TracChangeset for help on using the changeset viewer.