コード例 #1
0
ファイル: index.py プロジェクト: tintou/patacrep
    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)
コード例 #2
0
ファイル: test_authors.py プロジェクト: takuyozora/patacrep
 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))
コード例 #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)
コード例 #4
0
ファイル: test_authors.py プロジェクト: cbernet/patacrep
 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)
                 )
コード例 #5
0
ファイル: songs.py プロジェクト: angri/patacrep
 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 = []