def clean_unicode(value, replace_case=None, mapping_dict=None): value = to_unicode(value) get_letter = (mapping_dict or MAPPING).get if replace_case is not None: replace_case = to_unicode(replace_case) return unicode_join('', (get_letter(letter, replace_case) for letter in value)) else: return unicode_join('', (get_letter(letter, letter) for letter in value))
def create_rlike_filter(column, value): value = maybe_unicode(value) if value: words = value.split() if words: rlike_str = u('(%s)') % unicode_join('|', words) column = postgresql_non_ascii_and_lower(column) return column.op('rlike')(rlike_str.lower())
def method(value): number, key = metric_format(value) title = get_title(key) if title: title = translator(title) else: title = key return unicode_join(' ', [number, title])
def normalize_full_name(value): value = maybe_unicode(value) if value: words = [] for word in clean_unicode(value, replace_case='_').lower().split(): if word not in IGNORE_FULL_NAME_WORDS: words.append(word) if words: return unicode_join(' ', words) return u('')
def method(value): number = metric_format(value) return unicode_join(' ', [number, title])