Changeset 8478 for main/waeup.kofa


Ignore:
Timestamp:
21 May 2012, 07:17:50 (12 years ago)
Author:
Henrik Bettermann
Message:

Prepare script for migration of AAUE data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/tools/fix_import_file.py

    r7666 r8478  
    4040# Converter (see below)
    4141OPTIONS = {
     42    'student_id': 'student_id',
    4243    'sex': 'gender',
    4344    'birthday': 'date',
     
    5253    'password': 'password',
    5354    'phone': 'phone',
     55    'nationality': 'nationality',
    5456    'level': 'level',
    5557    'start_level': 'level',
     
    6668COLNAME_MAPPING = {
    6769    # base data
     70    'reg_state': 'state',
    6871    'jamb_reg_no': 'reg_number',
    6972    'matric_no': 'matric_number',
     
    9497    }
    9598
    96 # Mapping input regh_state --> output reg_state
     99# Mapping input state --> output state
    97100REGSTATE_MAPPING = {
    98101    'student_created': 'created',
     
    128131    """Converters to turn old-style values into new ones.
    129132    """
     133
     134    @classmethod
     135    def student_id(self, value):
     136        """ 'A123456' --> 'EA123456'
     137        """
     138        if len(value) == 7:
     139            return 'E' + value
     140        return value
     141
    130142    @classmethod
    131143    def reg_state(self, value):
     
    183195    def session(self, value):
    184196        """ '08' --> '2008'
    185         """
     197        '2008/2009' --> '2008'
     198        """
     199        if '/' in value:
     200            numbers = value.split('/')
     201            number = int(numbers[0])
     202            if number in range(2000,2015):
     203                return number
     204            else:
     205                return 9999
    186206        try:
    187207            number = int(value)
     
    274294
    275295    @classmethod
     296    def nationality(self, value):
     297        if value == "nigeria":
     298            return "NG"
     299        return value
     300
     301    @classmethod
    276302    def phone(self, value):
    277303        """ '<num-seq1>-<num-seq2> asd' -> '--<num-seq1><num-seq2>'
     
    284310        match = RE_PHONE.match(value)
    285311        phone = match.groups()[0]
    286         value = '--%s' % phone
     312        value = '-%s' % phone
    287313        return value
    288314
Note: See TracChangeset for help on using the changeset viewer.