Index: main/waeup.kofa/branches/uli-zc-async/tools/copy_media_files.py
===================================================================
--- main/waeup.kofa/branches/uli-zc-async/tools/copy_media_files.py	(revision 9209)
+++ main/waeup.kofa/branches/uli-zc-async/tools/copy_media_files.py	(revision 9211)
@@ -78,5 +78,5 @@
     return
 
-def copy_file(file_src, file_dst):
+def copy_file(src, dst):
     create_path(os.path.dirname(dst))
     print "COPY FILE: %s -> %s" % (file_src, file_dst)
Index: main/waeup.kofa/branches/uli-zc-async/tools/download_exports.sh
===================================================================
--- main/waeup.kofa/branches/uli-zc-async/tools/download_exports.sh	(revision 9209)
+++ 	(revision )
@@ -1,13 +1,0 @@
-#!/bin/sh
-
-## We expect at least three arguments...
-if [ $# -ne 3 ]; then
-    echo "Usage: $0 [user name] [password] [exporter]"
-    exit
-fi
-
-wget --save-cookies cookies.txt --keep-session-cookies --post-data "form.login=$1&form.password=$2" https://uniben-kofa.waeup.org/login 
-wget --load-cookies cookies.txt  --output-document $3.csv https://uniben-kofa.waeup.org/datacenter/export.csv?exporter=$3
-tar -czf Kofa$3.tar.gz $3.csv
-rm $3.csv
-mv Kofa$3.tar.gz /home/ftp/uniben
Index: main/waeup.kofa/branches/uli-zc-async/tools/fix_import_file.py
===================================================================
--- main/waeup.kofa/branches/uli-zc-async/tools/fix_import_file.py	(revision 9209)
+++ main/waeup.kofa/branches/uli-zc-async/tools/fix_import_file.py	(revision 9211)
@@ -65,4 +65,5 @@
     'sex': 'gender',
     'birthday': 'date',
+    'request_date': 'datetime',
     'marit_stat': 'marit_stat',
     'session': 'session',
@@ -84,29 +85,4 @@
     'lga': 'lga',
     'order_id': 'no_int',
-    'uniben': 'former',
-    'nysc_year': 'year',
-    'alr_date': 'date',
-    'fst_sit_date': 'date',
-    'scd_sit_date': 'date',
-    'emp_start': 'date',
-    'emp_end': 'date',
-    'emp_start2': 'date',
-    'emp_end2': 'date',
-    'fst_sit_results': 'result',
-    'scd_sit_results': 'result',
-    'alr_results': 'result',
-    'email': 'email',
-    'fst_sit_type': 'sittype',
-    'scd_sit_type': 'sittype',
-    'resp_pay_reference': 'no_int',
-    'type': 'company',
-    'date': 'date',
-    'core_or_elective': 'bool',
-    'category': 'p_category',
-    'reg_transition': 'reg_state',  # we completely change this column,
-                                    # since reg_state import is usually intended
-    'transition': 'reg_transition',
-    'payment_date': 'date',
-    'validation_date': 'date',
     }
 
@@ -114,26 +90,9 @@
 COLNAME_MAPPING = {
     # base data
-    'id': 'student_id',
     'reg_state': 'state',
-    'reg_transition': 'state',
     'jamb_reg_no': 'reg_number',
     'matric_no': 'matric_number',
     'birthday': 'date_of_birth',
     'clr_ac_pin': 'clr_code',
-    # clearance
-    'hq_grade': 'hq_degree',
-    'uniben': 'former_matric',
-    'hq_type2': 'hq2_type',
-    'hq_grade2': 'hq2_degree',
-    'hq_school2': 'hq2_school',
-    'hq_matric_no2': 'hq2_matric_no',
-    'hq_session2': 'hq2_session',
-    'hq_disc2': 'hq2_disc',
-    'emp': 'employer',
-    'emp2': 'employer2',
-    'emp_position2': 'emp2_position',
-    'emp_start2': 'emp2_start',
-    'emp_end2': 'emp2_end',
-    'emp_reason2': 'emp2_reason',
     # study course
     'study_course': 'certificate',
@@ -158,5 +117,4 @@
     'surcharge': 'surcharge_1',
     'session_id': 'p_session',
-    'type': 'r_company',
     }
 
@@ -173,6 +131,4 @@
     'courses_registered': 'courses registered',
     'courses_validated': 'courses validated',
-    'admit': 'admitted',
-    'return': 'returning'
     }
 
@@ -187,12 +143,9 @@
     """Replace input fieldnames by fieldnames of COLNAME_MAPPING.
     """
-    # Remove whitespaces
-    header = dict([(name, name.strip()) for name in fieldnames])
+    header = dict([(name, name) for name in fieldnames])
     for in_name, out_name in COLNAME_MAPPING.items():
-        if in_name not in header.values():
+        if in_name not in header:
             continue
-        # Inverse dictionary lookup
-        key = [key for key,value in header.items() if value==in_name][0]
-        header[key] = out_name
+        header[in_name] = out_name
     return header
 
@@ -202,13 +155,13 @@
 
     @classmethod
-    def student_id(self, value, row):
+    def student_id(self, value):
         """ 'A123456' --> 'EA123456'
         """
         if len(value) == 7:
-            return 'K' + value
-        return value
-
-    @classmethod
-    def reg_state(self, value, row):
+            return 'E' + value
+        return value
+
+    @classmethod
+    def reg_state(self, value):
         """ 'courses_validated' --> 'courses validated'
         """
@@ -216,15 +169,6 @@
 
     @classmethod
-    def reg_transition(self, value, row):
-        if value == "admitted":
-            return "admit"
-        if value == "returning":
-            return "return"
-        return value
-
-    @classmethod
-    def level(self, value, row):
+    def level(self, value):
         """ '000' --> '10'
-        '800' --> '999' if pg student
         """
         try:
@@ -234,10 +178,8 @@
         if number == 0:
             return 10
-        if row.get('entry_mode') and row.get('entry_mode').startswith('pg'):
-            return 999
         return number
 
     @classmethod
-    def semester(self, value, row):
+    def semester(self, value):
         """ '0' --> '9'
         """
@@ -251,5 +193,5 @@
 
     @classmethod
-    def application_category(self, value, row):
+    def application_category(self, value):
         """ '' --> 'no'
         """
@@ -259,26 +201,9 @@
 
     @classmethod
-    def lga(self, value, row):
+    def lga(self, value):
         """ Remove apostrophe
         """
         if value == 'akwa_ibom_uru_offong_oruko':
             return 'akwa_ibom_urue-offong-oruko'
-        if value == 'edo_ohionmwon':
-            return 'edo_orhionmwon'
-
-        if value == 'nassarawa_nassarawa':
-            return 'nassarawa_nassawara'
-
-        if value == 'kogi_mopa-muro-mopi':
-            return 'kogi_mopa-muro'
-
-        if value == 'delta_osimili-north':
-            return 'delta_oshielli-north'
-
-        if value == 'delta_osimili':
-            return 'delta_oshimili'
-
-        if value == 'delta_osimili-south':
-            return 'delta_oshimili-south'
         try:
             value = value.replace("'","")
@@ -295,5 +220,5 @@
 
     @classmethod
-    def session(self, value, row):
+    def session(self, value):
         """ '08' --> '2008'
         '2008/2009' --> '2008'
@@ -319,35 +244,5 @@
 
     @classmethod
-    def former(self, value, row):
-        """ True --> yes
-        '2008/2009' --> '2008'
-        """
-        if value == 'True':
-            return 'yes'
-        return
-
-    @classmethod
-    def bool(self, value, row):
-        """ True --> 1
-        """
-        if value in ('TRUE', 'True'):
-            return '1'
-        elif value in ('FALSE', 'False'):
-            return '0'
-        return
-
-    @classmethod
-    def year(self, value, row):
-        """ '0' --> ''
-        """
-        if value == '0':
-            return
-        if value == 'None':
-            return
-        return value
-
-
-    @classmethod
-    def marit_stat(self, value, row):
+    def marit_stat(self, value):
         """ 'True'/'False' --> 'married'/'unmarried'
         """
@@ -361,5 +256,5 @@
 
     @classmethod
-    def gender(self, value, row):
+    def gender(self, value):
         """ 'True'/'False' --> 'f'/'m'
         """
@@ -373,5 +268,5 @@
 
     @classmethod
-    def date(self, value, row):
+    def date(self, value):
         """ 'yyyy/mm/dd' --> 'yyyy-mm-dd'
         """
@@ -388,20 +283,31 @@
 
     @classmethod
-    def no_int(self, value, row):
-        """ Add hash and skip numbers starting with 999999
+    def no_int(self, value):
+        """ Add hash.
         """
         # We add the hash symbol to avoid automatic number transformation
         # in Excel and Calc for further processing
-        try:
-            intvalue = int(value)
-            value += '#'
-        except:
+        value += '#'
+        return value
+
+
+    @classmethod
+    def datetime(self, value):
+        """ 'yyyy/mm/dd' --> 'yyyy-mm-dd'
+        """
+        #print  "IN: ", value
+        if value == "None":
+            value = ""
+        elif value == "":
+            value = ""
+        else:
+            #value = datetime.datetime.strptime(value, '%Y/%m/%d')
+            #value = datetime.datetime.strftime(value, '%Y-%m-%d')
             pass
-        if value.startswith('999999'):
-            return
-        return value
-
-    @classmethod
-    def mode(self, value, row):
+        #print "OUT: ", value
+        return value
+
+    @classmethod
+    def mode(self, value):
         if value == "transfer_fulltime":
             return "transfer_ft"
@@ -411,5 +317,5 @@
 
     @classmethod
-    def password(self, value, row):
+    def password(self, value):
         if value == "not set":
             return ""
@@ -417,35 +323,11 @@
 
     @classmethod
-    def nationality(self, value, row):
+    def nationality(self, value):
         if value == "nigeria":
             return "NG"
-        if value == "niger":
-            return "NE"
-        return value
-
-    @classmethod
-    def sittype(self, value, row):
-        if value == "nabtec":
-            return "nabteb"
-        return value
-
-    @classmethod
-    def company(self, value, row):
-        if value == "online":
-            return "interswitch"
-        return value
-
-    @classmethod
-    def p_category(self, value, row):
-        if value == "acceptance":
-            return "clearance"
-        return value
-
-    @classmethod
-    def email(self, value, row):
-        return value.strip()
-
-    @classmethod
-    def phone(self, value, row):
+        return value
+
+    @classmethod
+    def phone(self, value):
         """ '<num-seq1>-<num-seq2> asd' -> '--<num-seq1><num-seq2>'
 
@@ -453,26 +335,10 @@
         of numbers.
         """
-        if not value:
-            return
-        value = value.strip('#')
         value = value.replace('-', '')
         value = value.replace('/', '')
         match = RE_PHONE.match(value)
         phone = match.groups()[0]
-        if value.startswith('234'):
-            value = '+' + value[:3] + '-' + value[3:]
-        else:
-            value = '-%s' % phone
-        return value + '#'
-
-    @classmethod
-    def result(self, value, row):
-        try:
-            liste = eval(value)
-        except:
-            return
-        if isinstance(liste,list):
-            return [(i[0].lower(),i[1]) for i in liste]
-        return
+        value = '-%s' % phone
+        return value
 
 
@@ -491,13 +357,5 @@
             header = convert_fieldnames(reader.fieldnames)
             writer.writerow(header)
-        if row.get('reg_state') == 'student_created':
-            # We do not reimport student records which have never been accessed.
-            continue
-        if row.get('status') == 'started':
-            # We do not reimport started payments.
-            continue
         for key, value in row.items():
-            # Remove unwanted whitespaces.
-            row[key] = row[key].strip()
             if not key in OPTIONS.keys():
                 continue
@@ -507,5 +365,5 @@
                 print "WARNING: cannot find converter %s" % conv_name
                 continue
-            row[key] = converter(row[key], row)
+            row[key] = converter(row[key])
         try:
             writer.writerow(row)
Index: main/waeup.kofa/branches/uli-zc-async/tools/reload_portraits.py
===================================================================
--- main/waeup.kofa/branches/uli-zc-async/tools/reload_portraits.py	(revision 9209)
+++ 	(revision )
@@ -1,107 +1,0 @@
-##
-## This script is called without parameters.
-##
-## It moves passport images from a reload folder to their right place in
-## the media folder.
-##
-## Configuration is done below.
-##
-##
-## Please note that for changing groups of files/directories, you
-## normally have to be root. This script is therefore normally run with
-## sudo.
-##
-
-## ######################################################################
-## CONFIGURATION
-##
-
-## The folder where all source docs can be found (can be any folder)
-#SRC_DIR = "/kofa/uniben/var/datacenter/media/students/reload"
-SRC_DIR = "/zope/instances/unibenpg-import/pictures_admitted_latest"
-
-## The students folder in Kofa where files should go to
-DST_DIR = "/kofa/uniben/var/datacenter/media/students"
-
-
-## Permissions to be set on new files/dirs. Set OWNER and/or GROUP to
-## None to leave them unchanged after creation.
-UMASK = 0664
-OWNER = 'kofa'
-GROUP = 'kofa'
-LETTER = 'B'
-
-##
-## CONFIGURATION END
-## ######################################################################
-
-import csv
-import os
-import shutil
-import sys
-from grp import getgrnam
-from pwd import getpwnam
-
-OWNER_ID = OWNER and getpwnam(OWNER)[2] or -1
-GRP_ID = GROUP and getgrnam(GROUP)[2] or -1
-DIR_UMASK = UMASK | 0111  # directories need extra x-permission
-
-def set_perms(path):
-    # set permissions and ownership for path
-    if os.path.isdir(path):
-        os.chmod(path, DIR_UMASK)
-    else:
-        os.chmod(path, UMASK)
-    os.chown(path, OWNER_ID, GRP_ID)
-    return
-
-def new_and_old_id(filename):
-    try:
-        stud_id, ext = filename.split('.')
-    except:
-        return None, None
-    if ext != 'jpg':
-        return None, None
-    if len(stud_id) == 7:
-        return LETTER + stud_id, stud_id
-    if len(stud_id) == 8:
-        return stud_id, stud_id
-    return None, None
-
-def final_subfolder(stud_id):
-    # compute new folder name from stud_id (old stud_ids or new stud_ids
-    # but not new old stud_ids)
-    num = int(stud_id[1:])
-    num = num / 10000 * 10
-    return '%05d' % num
-
-def copy_file(file_src, file_dst):
-    print "COPY FILE: %s -> %s" % (file_src, file_dst)
-    shutil.copyfile(file_src, file_dst)
-    set_perms(file_dst)
-    return
-
-if not os.path.exists(SRC_DIR):
-    sys.exit("No source folder %s. Skipping." % SRC_DIR)
-
-if len(os.listdir(SRC_DIR)) == 0:
-    sys.exit("Empty source folder for %s. Skipping." % SRC_DIR)
-
-for filename in os.listdir(SRC_DIR):
-    new_stud_id, stud_id = new_and_old_id(filename)
-    if not new_stud_id:
-        print "Wrong filename: %s" % filename
-        continue
-    subfolder = final_subfolder(stud_id)
-    dst_folder = os.path.join(DST_DIR, subfolder, new_stud_id)
-    if not os.path.exists(dst_folder):
-        print "Destination folder does not exist: %s. Skipping" % (dst_folder)
-        continue
-    dst_file = os.path.join(DST_DIR, subfolder, new_stud_id,
-        'passport_%s.jpg' % new_stud_id)
-    if os.path.exists(dst_file):
-        print "Destination file exists: %s. Skipping" % (dst_file)
-        continue
-    file_src = os.path.join(SRC_DIR, filename)
-    file_dst = os.path.join(dst_file)
-    copy_file(file_src, file_dst)
