Changeset 257


Ignore:
Timestamp:
20 Jun 2006, 14:50:46 (19 years ago)
Author:
joachim
Message:

=import from csv

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup_product/trunk/exportimport.py

    r256 r257  
    135135    logger = context.getLogger('loadfaculties')
    136136    logger.info('Start loading Faculties')
    137     faculties = csv.DictReader(open("%s/import/faculty.csv" % i_home,"rb"))
     137    try:
     138        faculties = csv.DictReader(open("%s/import/faculty.csv" % i_home,"rb"))
     139    except:
     140        return
    138141    l = site.portal_catalog({'meta_type': "Faculty"})
    139142    facs = {}
     
    157160    #return
    158161    logger = context.getLogger('loaddepartments')
    159     deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb"))
     162    try:
     163        deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb"))
     164    except:
     165        return
    160166    l = site.portal_catalog({'meta_type': "Faculty"})
    161167    facs = {}
     
    184190    #return
    185191    logger = context.getLogger('loadcourses')
    186     courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb"))
     192    try:
     193        courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb"))
     194    except:
     195        return
    187196    l = site.portal_catalog({'meta_type': "Faculty"})
    188197    facs = {}
     
    202211        if depid in deps.keys():
    203212            dept= deps.get(depid)
    204         elif depid in facs.keys():
    205             dept= facs.get(depid)
     213##        elif depid in facs.keys():
     214##            dept= facs.get(depid)
    206215        else:
    207216            logger.info("Dep %(Dept)s for Course %(CourseCode)s not found" % course)
     
    237246    #return
    238247    logger = context.getLogger('loadcertificates')
    239     certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb"))
     248    try:
     249        certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb"))
     250    except:
     251        return
    240252    f_ids = [f.id for f in site.portal_catalog({'meta_type': "Faculty"})]
    241253    #d_ids = [d.id for d in site.portal_catalog({'meta_type': "Department"})]
     
    344356def loadCertificateCoursesFromCSV(site,context): ###(
    345357    """install Certificate Courses from CSV values"""
    346     return
     358    #return
    347359    logger = context.getLogger('loadcertificatecourses')
    348     cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb"))
     360    try:
     361        cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb"))
     362    except:
     363        return
    349364    d_ids = [d.id for d in site.portal_catalog({'meta_type': "Department"})]
    350365    for cert_course in cert_courses:
Note: See TracChangeset for help on using the changeset viewer.