コード例 #1
0
def process_hindi_bracket(form, hindiKey1, hindiKey2,
                          englishCategoryName, meta,
                          oldPair = ['unknown', 'unknown']):
    hindiVal1 = form.getfirst(hindiKey1, '')
    hindiVal2 = form.getfirst(hindiKey2, '')
    if not hindiVal1 or not hindiVal2:
        return
    if hindiVal1 == ryw_hindi.UNTRANSLATED_STRING or \
       hindiVal2 == ryw_hindi.UNTRANSLATED_STRING:
        return
    englishVal1 = ryw_hindi.hindi_to_english(hindiVal1)
    englishVal2 = ryw_hindi.hindi_to_english(hindiVal2)
    if not englishVal1 or not englishVal2:
        ryw.give_bad_news(
            'process_hindi_bracket: warning: no hindi to english mapping: ' +
            ryw_hindi.html(hindiVal1) + ', ' + ryw_hindi.html(hindiVal2),
            logging.warning)
        return
    if englishVal1 == 'unknown' or englishVal2 == 'unknown':
        logging.debug('process_hindi_bracket: value is unknown: ' +
                      englishCategoryName)
        return

    if englishVal1 == oldPair[0] and englishVal2 == oldPair[1]:
        return
    
    meta[englishCategoryName] = [englishVal1, englishVal2]
    logging.debug('process_hindi_bracket: ' + englishCategoryName + ' = ' +
                  repr([englishVal1, englishVal2]))
    logging.debug('process_hindi_bracket: ' + repr(meta))
コード例 #2
0
def process_hindi_dropdown(englishKey, form, meta, oldVal = 'unknown'):
    hindiKey = 'hindi_' + englishKey
    hindiValue = form.getfirst(hindiKey, '')
    if hindiValue == '' or hindiValue == ryw_hindi.UNTRANSLATED_STRING:
        return
    englishValue = ryw_hindi.hindi_to_english(hindiValue)
    if englishValue == '':
        ryw.give_bad_news(
            'process_hindi_dropdown: warning: no hindi to english mapping: '+
            ryw_hindi.html(hindiValue), logging.warning)
        return
    if englishValue == 'unknown':
        logging.debug('process_hindi_dropdown: value is unknown: '+ englishKey)
        return

    if oldVal == englishValue:
        return
    
    meta[englishKey] = englishValue
    logging.debug('process_hindi_dropdown: ' + englishKey + ' = ' +
                  repr(englishValue))
    logging.debug('process_hindi_dropdown: ' + repr(meta))