MCPcopy Index your code
hub / github.com/python/cpython / EntryPoint

Class EntryPoint

Lib/importlib/metadata/__init__.py:146–314  ·  view source on GitHub ↗

An entry point as defined by Python packaging conventions. See `the packaging docs on entry points `_ for more information. >>> ep = EntryPoint( ... name=None, group=None, value='package.module:attr [extra1, extra2]

Source from the content-addressed store, hash-verified

144
145
146class EntryPoint:
147 """An entry point as defined by Python packaging conventions.
148
149 See `the packaging docs on entry points
150 <https://packaging.python.org/specifications/entry-points/>`_
151 for more information.
152
153 >>> ep = EntryPoint(
154 ... name=None, group=None, value='package.module:attr [extra1, extra2]')
155 >>> ep.module
156 'package.module'
157 >>> ep.attr
158 'attr'
159 >>> ep.extras
160 ['extra1', 'extra2']
161
162 If the value package or module are not valid identifiers, a
163 ValueError is raised on access.
164
165 >>> EntryPoint(name=None, group=None, value='invalid-name').module
166 Traceback (most recent call last):
167 ...
168 ValueError: (&#x27;Invalid object reference...invalid-name...
169 >>> EntryPoint(name=None, group=None, value='invalid-name').attr
170 Traceback (most recent call last):
171 ...
172 ValueError: (&#x27;Invalid object reference...invalid-name...
173 >>> EntryPoint(name=None, group=None, value='invalid-name').extras
174 Traceback (most recent call last):
175 ...
176 ValueError: (&#x27;Invalid object reference...invalid-name...
177
178 The same thing happens on construction.
179
180 >>> EntryPoint(name=None, group=None, value='invalid-name')
181 Traceback (most recent call last):
182 ...
183 ValueError: (&#x27;Invalid object reference...invalid-name...
184
185 """
186
187 pattern = re.compile(
188 r'(?P<module>[\w.]+)\s*'
189 r'(:\s*(?P<attr>[\w.]+)\s*)?'
190 r'((?P<extras>\[.*\])\s*)?$'
191 )
192 """
193 A regular expression describing the syntax for an entry point,
194 which might look like:
195
196 - module
197 - package.module
198 - package.module:attribute
199 - package.module:object.attribute
200 - package.module:attr [extra1, extra2]
201
202 Other combinations are possible as well.
203

Callers 4

test_positional_argsMethod · 0.90
test_sortableMethod · 0.90
_from_textMethod · 0.85

Calls 1

compileMethod · 0.45

Tested by 3

test_positional_argsMethod · 0.72
test_sortableMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…