Esempio n. 1
0
 def get_first_letter(key):
     """Return the uppercase first letter of key."""
     try:
         letter = FIRST_LETTER_PATTERN.match(normalize_string(key)).group(1)
     except AttributeError:
         # classify as number all the non letter characters
         letter = "0"
     if re.match(r'\d', letter):
         letter = '0-9'
     return letter.upper()
Esempio n. 2
0
 def get_first_letter(key):
     """Return the uppercase first letter of key."""
     try:
         letter = FIRST_LETTER_PATTERN.match(normalize_string(key)).group(1)
     except AttributeError:
         # classify as number all the non letter characters
         letter = "0"
     if re.match(r'\d', letter):
         letter = '0-9'
     return letter.upper()
Esempio n. 3
0
    def _raw_add(self, key, number, link):
        """Add a song to the list.

        No processing is done on data. It is added raw. See add() for a
        similar method with processing.
        """
        first = self.get_first_letter(key[0])
        if first not in self.data:
            self.data[first] = dict()
        if key not in self.data[first]:
            self.data[first][key] = {
                'sortingkey':
                [normalize_string(tex2plain(item)) for item in key],
                'entries': [],
            }
        self.data[first][key]['entries'].append({'num': number, 'link': link})
Esempio n. 4
0
    def _raw_add(self, key, number, link):
        """Add a song to the list.

        No processing is done on data. It is added raw. See add() for a
        similar method with processing.
        """
        first = self.get_first_letter(key[0])
        if first not in self.data:
            self.data[first] = dict()
        if key not in self.data[first]:
            self.data[first][key] = {
                'sortingkey': [
                    normalize_string(tex2plain(item))
                    for item in key
                    ],
                'entries': [],
                }
        self.data[first][key]['entries'].append({'num': number, 'link': link})
Esempio n. 5
0
def normalize_field(field):
    """Return a normalized field, it being a string or a list of strings."""
    if isinstance(field, str):
        return normalize_string(field)
    elif isinstance(field, list) or isinstance(field, tuple):
        return [normalize_field(string) for string in field]
Esempio n. 6
0
def normalize_field(field):
    """Return a normalized field, it being a string or a list of strings."""
    if isinstance(field, str):
        return normalize_string(field)
    elif isinstance(field, list) or isinstance(field, tuple):
        return [normalize_field(string) for string in field]