Ignore:
Timestamp:
27 Jan 2012, 18:26:20 (13 years ago)
Author:
Henrik Bettermann
Message:

Add converter for reg_state.

File:
1 edited

Legend:

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

    r7518 r7526  
    5555    'entry_session': 'session',
    5656    'current_session': 'session',
     57    'reg_state': 'reg_state',
     58    'password': 'password',
    5759    }
    5860
     
    6163    'jamb_reg_no': 'reg_number',
    6264    'birthday': 'date_of_birth',
     65    'clr_ac_pin': 'clr_code',
    6366    }
     67
     68# Mapping input regh_state --> output reg_state
     69REGSTATE_MAPPING = {
     70    'student_created': 'created',
     71    'admitted': 'admitted',
     72    'clearance_pin_entered': 'clearance started',
     73    'clearance_requested': 'clearance requested',
     74    'cleared_and_validated': 'cleared',
     75    'school_fee_paid': 'school fee paid',
     76    'returning': 'returning',
     77    'courses_registered': 'courses registered',
     78    'courses_validated': 'courses validated',
     79    }
     80
    6481##
    6582## END OF CONFIG
     
    83100    """Converters to turn old-style values into new ones.
    84101    """
     102
     103    @classmethod
     104    def reg_state(self, value):
     105        """ 'courses_validated' --> 'courses validated'
     106        """
     107        return REGSTATE_MAPPING.get(value,value)
     108
     109
    85110    @classmethod
    86111    def session(self, value):
     
    112137    @classmethod
    113138    def gender(self, value):
    114         """ 'True'/'False' --> 'female'/'male'
     139        """ 'True'/'False' --> 'f'/'m'
    115140        """
    116141        if value == 'True':
    117             value = 'female'
     142            value = 'f'
    118143        elif value == 'False':
    119             value = 'male'
     144            value = 'm'
    120145        else:
    121146            value = ''
     
    152177        #print "OUT: ", value
    153178        return value
     179
     180    @classmethod
     181    def password(self, value):
     182        if value == "not set":
     183            return ""
     184        return value
     185
    154186
    155187reader = csv.DictReader(open(INPUT_FILE, 'rb'))
Note: See TracChangeset for help on using the changeset viewer.