Exemplo n.º 1
0
    def add(self, key, number, link):
        """Add a song to the list.

        Process data before adding it.
        """
        if self.indextype == "TITLE":
            # Removing prefixes before titles
            for pattern in self.prefix_patterns:
                match = pattern.match(key)
                if match:
                    self._raw_add(
                        (
                            (match.group(2) + match.group(3)).strip(),
                            match.group(1).strip(),
                        ),
                        number,
                        link
                        )
                    return
            self._raw_add((key, ""), number, link)

        if self.indextype == "AUTHOR":
            # Processing authors
            for author in authors.processauthors(
                    key,
                    **self.authwords):
                self._raw_add(author, number, link)
Exemplo n.º 2
0
 def test_processauthors(self):
     """Test of :func:`patacrep.authors.processauthors` function."""
     for argument, expected in PROCESS_AUTHORS_DATA:
         with self.subTest(argument=argument, expected=expected):
             self.assertEqual(
                 set(authors.processauthors(argument, **AUTHWORDS)),
                 set(expected))
Exemplo n.º 3
0
    def add(self, key, number, link):
        """Add a song to the list.

        Process data before adding it.
        """
        if self.indextype == "TITLE":
            # Removing prefixes before titles
            for pattern in self.prefix_patterns:
                match = pattern.match(key)
                if match:
                    self._raw_add(
                        (
                            (match.group(2) + match.group(3)).strip(),
                            match.group(1).strip(),
                        ),
                        number,
                        link
                        )
                    return
            self._raw_add((key, ""), number, link)

        if self.indextype == "AUTHOR":
            # Processing authors
            for author in authors.processauthors(
                    key,
                    **self.authwords):
                self._raw_add(author, number, link)
Exemplo n.º 4
0
 def test_processauthors(self):
     """Test of :func:`patacrep.authors.processauthors` function."""
     for argument, expected in PROCESS_AUTHORS_DATA:
         with self.subTest(argument=argument, expected=expected):
             self.assertEqual(
                 set(
                     authors.processauthors(argument, **AUTHWORDS)
                 ),
                 set(expected)
                 )
Exemplo n.º 5
0
 def __init__(self, filename, config):
     # Data extraction from the song with plastex
     data = parsetex(filename)
     self.titles = data['titles']
     self.unprefixed_titles = [
             unprefixed_title(
                 unidecode(unicode(title, "utf-8")),
                 config['titleprefixwords']
                 )
             for title
             in self.titles
             ]
     self.args = data['args']
     self.path = filename
     self.languages = data['languages']
     if "by" in self.args.keys():
         self.authors = processauthors(
                 self.args["by"],
                 **config["authwords"]
                 )
     else:
         self.authors = []