Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
plugin.py
Go to the documentation of this file.
1
"""
2
pygments.plugin
3
~~~~~~~~~~~~~~~
4
5
Pygments plugin interface. By default, this tries to use
6
``importlib.metadata``, which is in the Python standard
7
library since Python 3.8, or its ``importlib_metadata``
8
backport for earlier versions of Python. It falls back on
9
``pkg_resources`` if not found. Finally, if ``pkg_resources``
10
is not found either, no plugins are loaded at all.
11
12
lexer plugins::
13
14
[pygments.lexers]
15
yourlexer = yourmodule:YourLexer
16
17
formatter plugins::
18
19
[pygments.formatters]
20
yourformatter = yourformatter:YourFormatter
21
/.ext = yourformatter:YourFormatter
22
23
As you can see, you can define extensions for the formatter
24
with a leading slash.
25
26
syntax plugins::
27
28
[pygments.styles]
29
yourstyle = yourstyle:YourStyle
30
31
filter plugin::
32
33
[pygments.filter]
34
yourfilter = yourfilter:YourFilter
35
36
37
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
38
:license: BSD, see LICENSE for details.
39
"""
40
41
LEXER_ENTRY_POINT =
'pygments.lexers'
42
FORMATTER_ENTRY_POINT =
'pygments.formatters'
43
STYLE_ENTRY_POINT =
'pygments.styles'
44
FILTER_ENTRY_POINT =
'pygments.filters'
45
46
47
def
iter_entry_points
(group_name):
48
try
:
49
from
importlib.metadata
import
entry_points
50
except
ImportError:
51
try
:
52
from
importlib_metadata
import
entry_points
53
except
ImportError:
54
try
:
55
from
pip._vendor.pkg_resources
import
iter_entry_points
56
except
(ImportError, OSError):
57
return
[]
58
else
:
59
return
iter_entry_points
(group_name)
60
groups = entry_points()
61
if
hasattr
(groups,
'select'
):
62
# New interface in Python 3.10 and newer versions of the
63
# importlib_metadata backport.
64
return
groups.select
(group=group_name)
65
else
:
66
# Older interface, deprecated in Python 3.10 and recent
67
# importlib_metadata, but we need it in Python 3.8 and 3.9.
68
return
groups.get
(group_name, [])
69
70
71
def
find_plugin_lexers
():
72
for
entrypoint
in
iter_entry_points
(LEXER_ENTRY_POINT):
73
yield
entrypoint.load
()
74
75
76
def
find_plugin_formatters
():
77
for
entrypoint
in
iter_entry_points
(FORMATTER_ENTRY_POINT):
78
yield
entrypoint.name
,
entrypoint.load
()
79
80
81
def
find_plugin_styles
():
82
for
entrypoint
in
iter_entry_points
(STYLE_ENTRY_POINT):
83
yield
entrypoint.name
,
entrypoint.load
()
84
85
86
def
find_plugin_filters
():
87
for
entrypoint
in
iter_entry_points
(FILTER_ENTRY_POINT):
88
yield
entrypoint.name
,
entrypoint.load
()
importlib.metadata
pip._vendor.pkg_resources
Definition
__init__.py:1
pip._vendor.pygments.plugin.find_plugin_formatters
find_plugin_formatters()
Definition
plugin.py:76
pip._vendor.pygments.plugin.find_plugin_filters
find_plugin_filters()
Definition
plugin.py:86
pip._vendor.pygments.plugin.find_plugin_lexers
find_plugin_lexers()
Definition
plugin.py:71
pip._vendor.pygments.plugin.find_plugin_styles
find_plugin_styles()
Definition
plugin.py:81
pip._vendor.pygments.plugin.iter_entry_points
iter_entry_points(group_name)
Definition
plugin.py:47
i
for i
Definition
prime_search.m:10
venv
lib
python3.12
site-packages
pip
_vendor
pygments
plugin.py
Generated by
1.9.8