Changeset 2997
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_utilities/ti_441_resolve_part2.py
r2982 r2997 16 16 def set_trace(): 17 17 pass 18 18 19 19 20 mtool = context.portal_membership … … 39 40 response.write("%s<br>\n\r" % s) 40 41 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 continue56 if state not in states:57 states.append(state)58 if lga not in lgas:59 lgas.append(lga)60 d[k] = v61 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) 62 63 64 difference = context.waeup_tool.difference 65 re_split = context.waeup_tool.re_split 63 66 #logger.info('') 64 67 student_records = context.students_catalog() … … 68 71 commit_after = 100 69 72 logger.info('started to fix %d records in students_catalog' % total) 70 d,states,lgas = getLGAs() 73 mapping = context.waeup_tool.getStatesLgas() 74 states = mapping['states'] 75 lgas = mapping['lgas'] 76 words_dict = mapping['word_dict'] 71 77 d = {} 72 78 for student_record in student_records: 73 79 # skip record without lga value 80 count += 1 74 81 if not student_record.lga: 75 82 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 79 85 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)) 81 87 continue 82 88 #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 continue90 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 continue95 count += 196 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 = False100 while True:101 if lga in lgas:102 found = True89 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 103 109 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) 111 115 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: 119 123 # break 120 124 to_edit = len(d) -
WAeUP_SRP/uniben/profiles/default/vocabularies/local_gov_areas.xml
r2680 r2997 13 13 <item key="abia_ikawuno" msgid="">Abia / Ikawuno</item> 14 14 <item key="abia_ikwuano" msgid="">Abia / Ikwuano</item> 15 <item key="abia_isiala-ngwa _north" msgid="">Abia / Isiala-NgwaNorth</item>16 <item key="abia_isiala-ngwa _south" msgid="">Abia / Isiala-NgwaSouth</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> 17 17 <item key="abia_isikwuato" msgid="">Abia / Isikwuato</item> 18 18 <item key="abia_isuikwuato" msgid="">Abia / Isuikwuato</item> … … 111 111 <item key="anambra_oti" msgid="">Anambra / Oti</item> 112 112 <item key="anambra_oyi" msgid="">Anambra / Oyi</item> 113 <item key="anambra_ubuluizor _ihiala" msgid="">Anambra / UbuluizorIhiala</item>113 <item key="anambra_ubuluizor-ihiala" msgid="">Anambra / Ubuluizor-Ihiala</item> 114 114 <item key="anambra_uyi" msgid="">Anambra / Uyi</item> 115 115 <item key="bauchi_alkaleri" msgid="">Bauchi / Alkaleri</item> … … 214 214 <item key="cross_river_yakurr" msgid="">Cross River / Yakurr</item> 215 215 <item key="cross_river_yala" msgid="">Cross River / Yala</item> 216 <item key="delta_aniocha_north" msgid="">Delta / Aniocha North</item>217 216 <item key="delta_aniocha-north" msgid="">Delta / Aniocha-North</item> 218 217 <item key="delta_aniocha-south" msgid="">Delta / Aniocha-South</item> … … 226 225 <item key="delta_ika-north-east" msgid="">Delta / Ika-North-East</item> 227 226 <item key="delta_ika-south" msgid="">Delta / Ika-South</item> 228 <item key="delta_i kpemili" msgid="">Delta / Ikpemili</item>227 <item key="delta_idemili-south" msgid="">Delta / Idemili-South</item> 229 228 <item key="delta_isoko-north" msgid="">Delta / Isoko-North</item> 230 229 <item key="delta_isoko-south" msgid="">Delta / Isoko-South</item> … … 234 233 <item key="delta_ndokwa-west" msgid="">Delta / Ndokwa-West</item> 235 234 <item key="delta_okpe" msgid="">Delta / Okpe</item> 235 <item key="delta_okwuani" msgid="">Delta / Okwuani</item> 236 236 <item key="delta_oleh" msgid="">Delta / Oleh</item> 237 237 <item key="delta_oshielli-north" msgid="">Delta / Oshielli-North</item> … … 275 275 <item key="edo_afuze" msgid="">Edo / Afuze</item> 276 276 <item key="edo_agbazilo" msgid="">Edo / Agbazilo</item> 277 <item key="edo_akoko_edo" msgid="">Edo / Akoko Edo</item>278 277 <item key="edo_akoko-edo" msgid="">Edo / Akoko-Edo</item> 279 278 <item key="edo_egor" msgid="">Edo / Egor</item> 280 279 <item key="edo_esan-central" msgid="">Edo / Esan-Central</item> 281 280 <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> 282 282 <item key="edo_esan-south-east" msgid="">Edo / Esan-South-East</item> 283 283 <item key="edo_esan-west" msgid="">Edo / Esan-West</item> … … 291 291 <item key="edo_opoji_irrua" msgid="">Edo / Opoji Irrua</item> 292 292 <item key="edo_oredo" msgid="">Edo / Oredo</item> 293 <item key="edo_o rhionmwon" msgid="">Edo / Orhionmwon</item>293 <item key="edo_ohionmwon" msgid="">Edo / Ohionmwon</item> 294 294 <item key="edo_ovia-north-east" msgid="">Edo / Ovia-North-East</item> 295 295 <item key="edo_ovia-south-west" msgid="">Edo / Ovia-South-West</item> 296 <item key="edo_owan_east" msgid="">Edo / Owan East</item>297 296 <item key="edo_owan-east" msgid="">Edo / Owan-East</item> 298 297 <item key="edo_owan-west" msgid="">Edo / Owan-West</item> … … 663 662 <item key="ondo_akoko-south" msgid="">Ondo / Akoko-South</item> 664 663 <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> 665 665 <item key="ondo_akure" msgid="">Ondo / Akure</item> 666 666 <item key="ondo_akure-north" msgid="">Ondo / Akure-North</item> … … 678 678 <item key="ondo_ondo" msgid="">Ondo / Ondo</item> 679 679 <item key="ondo_ondo-east" msgid="">Ondo / Ondo-East</item> 680 <item key="ondo_ondo-west" msgid="">Ondo / Ondo-West</item> 680 681 <item key="ondo_ose" msgid="">Ondo / Ose</item> 681 682 <item key="ondo_owo" msgid="">Ondo / Owo</item> … … 687 688 <item key="osun_boripe" msgid="">Osun / Boripe</item> 688 689 <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> 690 691 <item key="osun_egbedore" msgid="">Osun / Egbedore</item> 691 692 <item key="osun_ejigbo" msgid="">Osun / Ejigbo</item> 692 693 <item key="osun_ife" msgid="">Osun / Ife</item> 693 <item key="osun_ife _north" msgid="">Osun / IfeNorth</item>694 <item key="osun_ife _south" msgid="">Osun / IfeSouth</item>694 <item key="osun_ife-north" msgid="">Osun / Ife-North</item> 695 <item key="osun_ife-south" msgid="">Osun / Ife-South</item> 695 696 <item key="osun_ife-central" msgid="">Osun / Ife-Central</item> 696 697 <item key="osun_ife-east" msgid="">Osun / Ife-East</item> … … 867 868 <item key="bayelsa_southern-ijaw" msgid="">Bayelsa / Southern-Ijaw</item> 868 869 <item key="akwa_ibom_ibiono-ibom" msgid="">Akwa Ibom / Ibiono-Ibom</item> 869 <item key="delta_idemili-south" msgid="">Delta / Idemili-South</item>870 870 <item key="oyo_itesiwaju" msgid="">Oyo / Itesiwaju</item> 871 871 <item key="kogi_mopa-muro" msgid="">Kogi / Mopa-Muro</item>
Note: See TracChangeset for help on using the changeset viewer.