Ignore:
Timestamp:
20 Mar 2007, 18:26:23 (18 years ago)
Author:
joachim
Message:

fixAllNames enhanced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r1602 r1611  
    762762            if not old_first and not old_middle and old_last:
    763763                new_names = [n.capitalize() for n in old_last.split()]
    764                 if len(new_names) > 3:
     764                if len(new_names) > 1:
    765765                    old_first = new_names[0]
    766                     old_last = new_names[1]
    767                     old_middle = ' '.join(new_names[2:])
    768                 elif len(new_names) == 3:
    769                     old_first = new_names[0]
    770                     old_last = new_names[1]
    771                     old_middle = new_names[2]
    772                 elif len(new_names) == 2:
    773                     old_first = new_names[0]
    774                     old_last = new_names[1]
    775                     old_middle = ''
    776                 elif len(new_names) == 1:
     766                    old_last = new_names[-1]
     767                    old_middle = ' '.join(new_names[1:-1])
     768                else:
    777769                    old_last = new_names[0]
    778770                    old_first = ''
    779771                    old_middle = ''
    780             if old_last:
    781                 new_first = old_last
     772            if old_first:
     773                new_first = old_first
    782774            if old_middle:
    783775                new_middle = old_middle
    784             if old_first:
    785                 new_last = old_first
    786 
     776            if old_last:
     777                new_last = old_last
    787778            if old_first.find('<') != -1 or\
    788779               old_first.find('>') != -1 or\
     
    793784                   invalid = "invalid characters"
    794785        else:
    795             if old_first and old_middle and old_last:
    796                 new_first = old_first.capitalize()
    797                 new_middle = old_middle.capitalize()
    798                 new_last = old_last.capitalize()
    799             elif old_first and not old_middle and old_last:
    800                 new_names = [n.capitalize() for n in old_first.split()]
    801                 if len(new_names) > 1:
    802                     new_first = new_names[0]
    803                     new_middle = ' '.join(new_names[1:])
    804                 else:
    805                     new_first = old_first.capitalize()
    806                     new_middle = ''
    807                 new_last = old_last.capitalize()
    808             elif not old_first and not old_middle and old_last:
     786            new_first = old_first
     787            if new_first.strip() == '-':
    809788                new_first = ''
     789            new_middle = old_middle
     790            if new_middle.strip() == '-':
    810791                new_middle = ''
    811                 new_last = old_last.capitalize()
    812             else:
    813                 new_first = ''
    814                 new_middle = ''
     792            new_last = old_last
     793            if new_last.strip() == '-':
    815794                new_last = ''
    816         name = "%(new_last)s %(new_first)s %(new_middle)s" % vars()
     795        name = "%(new_first)s %(new_middle)s %(new_last)s" % vars()
    817796        if new_student:
    818797            text = "New"
Note: See TracChangeset for help on using the changeset viewer.