File: contributors.py

package info (click to toggle)
quodlibet 4.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,228 kB
  • sloc: python: 89,728; sh: 381; xml: 110; makefile: 91
file content (30 lines) | stat: -rw-r--r-- 846 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from docutils.parsers.rst import Directive
from docutils.nodes import paragraph


class ContributorsDirective(Directive):
    required_arguments = 1
    has_content = True

    def run(self):
        role = self.arguments[0]

        roles = ["authors", "translators", "artists"]
        if role not in roles:
            raise Exception(f"Argument must be in {roles}")

        const = self.state.document.settings.env.config.const
        if role == "authors":
            people = const.AUTHORS
        elif role == "translators":
            people = const.TRANSLATORS
        else:
            people = const.ARTISTS

        output = ", ".join(people)
        return [paragraph(text=output)]


def setup(app):
    app.add_directive("contributors", ContributorsDirective)
    return {"parallel_read_safe": True, "parallel_write_safe": True}