示例#1
0
    def normalize_operands(self, a, b):

        if self.normalized_strings:
            if a is not None:
                a = normalize(a)
            if not self._invariable_normalized and b is not None:
                b = normalize(b)

        return a, b
示例#2
0
def escape_ga_string(id):
    if id:
        id = html_to_plain_text(id)
        id = normalize(id)
        id = _escape_ga_string_nonword_expr.sub("-", id).strip("-")
        id = _escape_ga_string_repeat_expr.sub("-", id)
    return id
示例#3
0
 def normalize_invariable(self):
     self.operands = (
         self.operands[0],
         Constant(normalize(self.operands[1].eval()))
     )
示例#4
0
 def normalize(self, text, preserve_patterns=False):
     return normalize(text,
                      normalization_map=self.pattern_normalization
                      if preserve_patterns else self.normalization)
示例#5
0
 def get_sorting_key(self):
     return normalize(translations(self))
示例#6
0
 def get_group_sorting_key(self, grouping):
     if self.sort_groups_alphabetically:
         return normalize(translations(grouping))
     else:
         return grouping.key
示例#7
0
 def get_item_sorting_key(self, item):
     return normalize(translations(item))
示例#8
0
def _string_get_index_value(self, value):
    if value is not None and self.normalized_index:
        return normalize(value)
    else:
        return value