Changeset 3155


Ignore:
Timestamp:
13 Feb 2008, 14:18:58 (17 years ago)
Author:
joachim
Message:

fix for overwritten course_results, pending_only import fixed to not
overwrite empty values.

Location:
WAeUP_SRP/base
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r3148 r3155  
    21212121        #
    21222122        not_imported_keys = import_keys + ["Error",]
    2123         not_imported_file = open(not_imported_fn,"a")
     2123        not_imported_file = open(not_imported_fn,"w")
    21242124        not_imported_csv_writer = csv.DictWriter(not_imported_file,
    21252125                                                    not_imported_keys,
     
    21342134        if 'id' not in imported_keys:
    21352135            imported_keys.insert(0,"id")
    2136         imported_file = open(imported_fn,"a")
     2136        imported_file = open(imported_fn,"w")
    21372137        imported_csv_writer = csv.DictWriter(imported_file,
    21382138                                             imported_keys,
     
    21782178                pending_imported_ids = []
    21792179                pending_imported = []
    2180                 for item in pending_records.values():
     2180                for record in pending_records.values():
     2181                    item = {}
     2182                    for k,v in record.items():
     2183                        if v:
     2184                            item[k] = v
    21812185                    results = importer(item)
    21822186                    id = results[0]
     
    21852189                    if is_pending:
    21862190                        continue
    2187                     if error:
    2188                         continue
    2189                     msg = format % item
     2191                    del item['Error']
     2192                    msg = ";".join(["%s : %s" % (k,v) for k,v in item.items()])
    21902193                    logger.info("imported from %(pending_fn)s %(msg)s" % vars())
    21912194                    pending_imported.append(item)
    21922195                    pending_imported_ids += id,
    21932196                    total_pending_imported = len(pending_imported_ids)
    2194                 logger.info("imported %d pending imports" % len(pending_imported_ids))
     2197                    logger.info("imported %d pending imports" % len(pending_imported_ids))
    21952198                for id in pending_imported_ids:
    2196                     if pending_records.has_key(id):
    2197                         del pending_records[id]
     2199                    del pending_records[id]
    21982200            pending_imports_file = open(pending_fn,'w')
    21992201            pending_csv_writer = csv.DictWriter(pending_imports_file,
Note: See TracChangeset for help on using the changeset viewer.