Changeset 2997


Ignore:
Timestamp:
8 Jan 2008, 18:33:19 (17 years ago)
Author:
joachim
Message:

should fix all fixable, some lgas have been added some edited to/in
local_gov_areas.xml

Location:
WAeUP_SRP
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_utilities/ti_441_resolve_part2.py

    r2982 r2997  
    1616    def set_trace():
    1717        pass
     18
    1819
    1920mtool = context.portal_membership
     
    3940    response.write("%s<br>\n\r" % s)
    4041
    41 def getLGAs():
    42     voc = getattr(context.portal_vocabularies,'local_gov_areas')
    43     states = []
    44     lgas  = []
    45     d = {}
    46     for k,v in voc.items():
    47         parts = v.split(' / ')
    48         if len(parts) == 1:
    49             state = parts[0].lower()
    50             lga = ""
    51         elif len(parts) == 2:
    52             state = parts[0].lower()
    53             lga = "_".join(parts[1].lower().split())
    54         else:
    55             continue
    56         if state not in states:
    57             states.append(state)
    58         if lga not in lgas:
    59             lgas.append(lga)
    60         d[k] = v
    61     return (d,states,lgas)
     42# def getLGAs():
     43#     voc = getattr(context.portal_vocabularies,'local_gov_areas')
     44#     states = []
     45#     lgas  = []
     46#     d = {}
     47#     for k,v in voc.items():
     48#         parts = v.split(' / ')
     49#         if len(parts) == 1:
     50#             state = parts[0].lower()
     51#             lga = ""
     52#         elif len(parts) == 2:
     53#             state = parts[0].lower()
     54#             lga = "_".join(parts[1].lower().split())
     55#         else:
     56#             continue
     57#         if state not in states:
     58#             states.append(state)
     59#         if lga not in lgas:
     60#             lgas.append(lga)
     61#         d[k] = v
     62#     return (d,states,lgas)
    6263
     64difference = context.waeup_tool.difference
     65re_split = context.waeup_tool.re_split
    6366#logger.info('')
    6467student_records = context.students_catalog()
     
    6871commit_after = 100
    6972logger.info('started to fix %d records in students_catalog' % total)
    70 d,states,lgas = getLGAs()
     73mapping = context.waeup_tool.getStatesLgas()
     74states = mapping['states']
     75lgas = mapping['lgas']
     76words_dict = mapping['word_dict']
    7177d = {}
    7278for student_record in student_records:
    7379    # skip record without lga value
     80    count += 1
    7481    if not student_record.lga:
    7582        continue
    76     #skip records with correct lga key value
    77     if student_record.lga.find('_') > -1:
    78         continue
     83    # if student_record.lga.find(' ') < 0:
     84    #     continue
    7985    if student_record.lga.startswith('no state'):
    80         logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
     86        #logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
    8187        continue
    8288    #rwrite("%s: %s" % (student_record.id,student_record.lga))
    83     sl = student_record.lga.split(' / ')
    84     if len(sl) != 2:
    85         sl = student_record.lga.split('/')
    86         if len(sl) != 2:
    87             logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
    88             #rwrite("wrong size %s: %s" % (student_record.id,sl))
    89             continue
    90     state = sl[0].lower().strip()
    91     lga = sl[1].lower().strip()
    92     if not lga or not state:
    93         logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
    94         continue
    95     count += 1
    96     if len(d) and not len(d)  % commit_after:
    97         logger.info("found %d correct state/lga combinations of %d so far" % (len(d),count))
    98     if state in states:
    99         found = False
    100         while True:
    101             if lga in lgas:
    102                 found = True
     89    words = student_record.lga
     90    if len(words.split(' / ')) == 2:
     91        words = words.replace(' / ',' ')
     92    words = re_split('[^a-zA-Z0-9/]',words)
     93    lga_words = []
     94    for word in words:
     95        if word:
     96            lga_words += word.lower(),
     97    lga_words.sort()
     98    # state = sl[0].lower().strip()
     99    # state = '_'.join(state.split())
     100    # lga = sl[1].lower().strip()
     101    # if not lga or not state:
     102    #     logger.info("found invalid lga %s of %s" % (student_record.lga,student_record.id))
     103    #     continue
     104    state_lga = ''
     105    while not state_lga:
     106        for k,l in words_dict.items():
     107            if lga_words == l:
     108                state_lga = k
    103109                break
    104             lga = lga.replace(' ','-')
    105             if lga in lgas:
    106                 found = True
    107             break
    108         if found:
    109             #msg = "found %s for %s" % (state_lga,student_record.id)
    110             state_lga = state + '_' + lga
     110        break
     111    if state_lga:
     112        if state_lga != student_record.lga:
     113            msg = "found %s is %s for %s " % (state_lga,student_record.lga,student_record.id)
     114            #rwrite(msg)
    111115            d[student_record.id] = state_lga
    112         #else:
    113             #msg = "no '%s' '%s' for %s" % (state,lga,student_record.id)
    114             #rwrite(msg)
    115     #else:
    116         #msg = "no state '%s' '%s' for %s" % (state,lga,student_record.id)
    117         #rwrite(msg)
    118     # if count > 150:
     116            if len(d) and not len(d)  % commit_after:
     117                logger.info("found %d to correct state/lga combinations of %d so far" % (len(d),count))
     118        else:
     119            msg = "already corrected %s : %s for %s " % (state_lga,student_record.lga,student_record.id)
     120    else:
     121        msg = "no '%s' for %s" % (lga_words,student_record.id)
     122    # if count > 2000:
    119123    #     break
    120124to_edit = len(d)
  • WAeUP_SRP/uniben/profiles/default/vocabularies/local_gov_areas.xml

    r2680 r2997  
    1313    <item key="abia_ikawuno" msgid="">Abia / Ikawuno</item>
    1414    <item key="abia_ikwuano" msgid="">Abia / Ikwuano</item>
    15     <item key="abia_isiala-ngwa_north" msgid="">Abia / Isiala-Ngwa North</item>
    16     <item key="abia_isiala-ngwa_south" msgid="">Abia / Isiala-Ngwa South</item>
     15    <item key="abia_isiala-ngwa-north" msgid="">Abia / Isiala-Ngwa-North</item>
     16    <item key="abia_isiala-ngwa-south" msgid="">Abia / Isiala-Ngwa-South</item>
    1717    <item key="abia_isikwuato" msgid="">Abia / Isikwuato</item>
    1818    <item key="abia_isuikwuato" msgid="">Abia / Isuikwuato</item>
     
    111111    <item key="anambra_oti" msgid="">Anambra / Oti</item>
    112112    <item key="anambra_oyi" msgid="">Anambra / Oyi</item>
    113     <item key="anambra_ubuluizor_ihiala" msgid="">Anambra / Ubuluizor Ihiala</item>
     113    <item key="anambra_ubuluizor-ihiala" msgid="">Anambra / Ubuluizor-Ihiala</item>
    114114    <item key="anambra_uyi" msgid="">Anambra / Uyi</item>
    115115    <item key="bauchi_alkaleri" msgid="">Bauchi / Alkaleri</item>
     
    214214    <item key="cross_river_yakurr" msgid="">Cross River / Yakurr</item>
    215215    <item key="cross_river_yala" msgid="">Cross River / Yala</item>
    216     <item key="delta_aniocha_north" msgid="">Delta / Aniocha North</item>
    217216    <item key="delta_aniocha-north" msgid="">Delta / Aniocha-North</item>
    218217    <item key="delta_aniocha-south" msgid="">Delta / Aniocha-South</item>
     
    226225    <item key="delta_ika-north-east" msgid="">Delta / Ika-North-East</item>
    227226    <item key="delta_ika-south" msgid="">Delta / Ika-South</item>
    228     <item key="delta_ikpemili" msgid="">Delta / Ikpemili</item>
     227    <item key="delta_idemili-south" msgid="">Delta / Idemili-South</item>
    229228    <item key="delta_isoko-north" msgid="">Delta / Isoko-North</item>
    230229    <item key="delta_isoko-south" msgid="">Delta / Isoko-South</item>
     
    234233    <item key="delta_ndokwa-west" msgid="">Delta / Ndokwa-West</item>
    235234    <item key="delta_okpe" msgid="">Delta / Okpe</item>
     235    <item key="delta_okwuani" msgid="">Delta / Okwuani</item>
    236236    <item key="delta_oleh" msgid="">Delta / Oleh</item>
    237237    <item key="delta_oshielli-north" msgid="">Delta / Oshielli-North</item>
     
    275275    <item key="edo_afuze" msgid="">Edo / Afuze</item>
    276276    <item key="edo_agbazilo" msgid="">Edo / Agbazilo</item>
    277     <item key="edo_akoko_edo" msgid="">Edo / Akoko Edo</item>
    278277    <item key="edo_akoko-edo" msgid="">Edo / Akoko-Edo</item>
    279278    <item key="edo_egor" msgid="">Edo / Egor</item>
    280279    <item key="edo_esan-central" msgid="">Edo / Esan-Central</item>
    281280    <item key="edo_esan-north-east" msgid="">Edo / Esan-North-East</item>
     281    <item key="edo_esan-north-west" msgid="">Edo / Esan-North-West</item>
    282282    <item key="edo_esan-south-east" msgid="">Edo / Esan-South-East</item>
    283283    <item key="edo_esan-west" msgid="">Edo / Esan-West</item>
     
    291291    <item key="edo_opoji_irrua" msgid="">Edo / Opoji Irrua</item>
    292292    <item key="edo_oredo" msgid="">Edo / Oredo</item>
    293     <item key="edo_orhionmwon" msgid="">Edo / Orhionmwon</item>
     293    <item key="edo_ohionmwon" msgid="">Edo / Ohionmwon</item>
    294294    <item key="edo_ovia-north-east" msgid="">Edo / Ovia-North-East</item>
    295295    <item key="edo_ovia-south-west" msgid="">Edo / Ovia-South-West</item>
    296     <item key="edo_owan_east" msgid="">Edo / Owan East</item>
    297296    <item key="edo_owan-east" msgid="">Edo / Owan-East</item>
    298297    <item key="edo_owan-west" msgid="">Edo / Owan-West</item>
     
    663662    <item key="ondo_akoko-south" msgid="">Ondo / Akoko-South</item>
    664663    <item key="ondo_akoko-south-east" msgid="">Ondo / Akoko-South-East</item>
     664    <item key="ondo_akoko-south-west" msgid="">Ondo / Akoko-South-West</item>
    665665    <item key="ondo_akure" msgid="">Ondo / Akure</item>
    666666    <item key="ondo_akure-north" msgid="">Ondo / Akure-North</item>
     
    678678    <item key="ondo_ondo" msgid="">Ondo / Ondo</item>
    679679    <item key="ondo_ondo-east" msgid="">Ondo / Ondo-East</item>
     680    <item key="ondo_ondo-west" msgid="">Ondo / Ondo-West</item>
    680681    <item key="ondo_ose" msgid="">Ondo / Ose</item>
    681682    <item key="ondo_owo" msgid="">Ondo / Owo</item>
     
    687688    <item key="osun_boripe" msgid="">Osun / Boripe</item>
    688689    <item key="osun_ede" msgid="">Osun / Ede</item>
    689     <item key="osun_ede_north" msgid="">Osun / Ede North</item>
     690    <item key="osun_ede-north" msgid="">Osun / Ede North</item>
    690691    <item key="osun_egbedore" msgid="">Osun / Egbedore</item>
    691692    <item key="osun_ejigbo" msgid="">Osun / Ejigbo</item>
    692693    <item key="osun_ife" msgid="">Osun / Ife</item>
    693     <item key="osun_ife_north" msgid="">Osun / Ife North</item>
    694     <item key="osun_ife_south" msgid="">Osun / Ife South</item>
     694    <item key="osun_ife-north" msgid="">Osun / Ife-North</item>
     695    <item key="osun_ife-south" msgid="">Osun / Ife-South</item>
    695696    <item key="osun_ife-central" msgid="">Osun / Ife-Central</item>
    696697    <item key="osun_ife-east" msgid="">Osun / Ife-East</item>
     
    867868    <item key="bayelsa_southern-ijaw" msgid="">Bayelsa / Southern-Ijaw</item>
    868869    <item key="akwa_ibom_ibiono-ibom" msgid="">Akwa Ibom / Ibiono-Ibom</item>
    869     <item key="delta_idemili-south" msgid="">Delta / Idemili-South</item>
    870870    <item key="oyo_itesiwaju" msgid="">Oyo / Itesiwaju</item>
    871871    <item key="kogi_mopa-muro" msgid="">Kogi / Mopa-Muro</item>
Note: See TracChangeset for help on using the changeset viewer.