Changeset 9009
- Timestamp:
- 17 Jul 2012, 05:30:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/tools/fix_import_file.py
r9007 r9009 111 111 COLNAME_MAPPING = { 112 112 # base data 113 'id': 'student_id', 113 114 'reg_state': 'state', 114 115 'reg_transition': 'state', … … 184 185 """ 185 186 header = dict([(name, name) for name in fieldnames]) 187 # Remove whitespaces 188 for key in header: 189 header[key] = key.strip() 186 190 for in_name, out_name in COLNAME_MAPPING.items(): 187 191 if in_name not in header: … … 195 199 196 200 @classmethod 197 def student_id(self, value ):201 def student_id(self, value, row): 198 202 """ 'A123456' --> 'EA123456' 199 203 """ … … 203 207 204 208 @classmethod 205 def reg_state(self, value ):209 def reg_state(self, value, row): 206 210 """ 'courses_validated' --> 'courses validated' 207 211 """ … … 209 213 210 214 @classmethod 211 def reg_transition(self, value ):215 def reg_transition(self, value, row): 212 216 if value == "admitted": 213 217 return "admit" … … 217 221 218 222 @classmethod 219 def level(self, value ):223 def level(self, value, row): 220 224 """ '000' --> '10' 225 '800' --> '999' if pg student 221 226 """ 222 227 try: … … 226 231 if number == 0: 227 232 return 10 233 if row.get('entry_mode').startswith('pg'): 234 return 999 228 235 return number 229 236 230 237 @classmethod 231 def semester(self, value ):238 def semester(self, value, row): 232 239 """ '0' --> '9' 233 240 """ … … 241 248 242 249 @classmethod 243 def application_category(self, value ):250 def application_category(self, value, row): 244 251 """ '' --> 'no' 245 252 """ … … 249 256 250 257 @classmethod 251 def lga(self, value ):258 def lga(self, value, row): 252 259 """ Remove apostrophe 253 260 """ … … 285 292 286 293 @classmethod 287 def session(self, value ):294 def session(self, value, row): 288 295 """ '08' --> '2008' 289 296 '2008/2009' --> '2008' … … 309 316 310 317 @classmethod 311 def former(self, value ):318 def former(self, value, row): 312 319 """ True --> yes 313 320 '2008/2009' --> '2008' … … 318 325 319 326 @classmethod 320 def year(self, value ):327 def year(self, value, row): 321 328 """ '0' --> '' 322 329 """ … … 329 336 330 337 @classmethod 331 def marit_stat(self, value ):338 def marit_stat(self, value, row): 332 339 """ 'True'/'False' --> 'married'/'unmarried' 333 340 """ … … 341 348 342 349 @classmethod 343 def gender(self, value ):350 def gender(self, value, row): 344 351 """ 'True'/'False' --> 'f'/'m' 345 352 """ … … 353 360 354 361 @classmethod 355 def date(self, value ):362 def date(self, value, row): 356 363 """ 'yyyy/mm/dd' --> 'yyyy-mm-dd' 357 364 """ … … 368 375 369 376 @classmethod 370 def no_int(self, value ):377 def no_int(self, value, row): 371 378 """ Add hash and skip numbers starting with 999999 372 379 """ … … 383 390 384 391 @classmethod 385 def mode(self, value ):392 def mode(self, value, row): 386 393 if value == "transfer_fulltime": 387 394 return "transfer_ft" … … 391 398 392 399 @classmethod 393 def password(self, value ):400 def password(self, value, row): 394 401 if value == "not set": 395 402 return "" … … 397 404 398 405 @classmethod 399 def nationality(self, value ):406 def nationality(self, value, row): 400 407 if value == "nigeria": 401 408 return "NG" … … 405 412 406 413 @classmethod 407 def sittype(self, value ):414 def sittype(self, value, row): 408 415 if value == "nabtec": 409 416 return "nabteb" … … 411 418 412 419 @classmethod 413 def company(self, value ):420 def company(self, value, row): 414 421 if value == "online": 415 422 return "interswitch" … … 417 424 418 425 @classmethod 419 def p_category(self, value ):426 def p_category(self, value, row): 420 427 if value == "acceptance": 421 428 return "clearance" … … 423 430 424 431 @classmethod 425 def email(self, value ):432 def email(self, value, row): 426 433 return value.strip() 427 434 428 435 @classmethod 429 def phone(self, value ):436 def phone(self, value, row): 430 437 """ '<num-seq1>-<num-seq2> asd' -> '--<num-seq1><num-seq2>' 431 438 … … 447 454 448 455 @classmethod 449 def result(self, value ):456 def result(self, value, row): 450 457 try: 451 458 liste = eval(value) … … 472 479 writer.writerow(header) 473 480 if row.get('reg_state') == 'student_created': 481 # We do not reimport student records which have never been accessed. 474 482 continue 475 483 if row.get('status') == 'started': 476 # We do not use started payments484 # We do not reimport started payments. 477 485 continue 478 486 for key, value in row.items(): 487 # Remove unwanted whitespaces. 488 row[key] = row[key].strip() 479 489 if not key in OPTIONS.keys(): 480 490 continue … … 484 494 print "WARNING: cannot find converter %s" % conv_name 485 495 continue 486 row[key] = converter(row[key] )496 row[key] = converter(row[key], row) 487 497 try: 488 498 writer.writerow(row)
Note: See TracChangeset for help on using the changeset viewer.