@@ -128,6 +128,15 @@ class EntryPoint(
128
128
See `the packaging docs on entry points
129
129
<https://packaging.python.org/specifications/entry-points/>`_
130
130
for more information.
131
+
132
+ >>> ep = EntryPoint(
133
+ ... name=None, group=None, value='package.module:attr [extra1, extra2]')
134
+ >>> ep.module
135
+ 'package.module'
136
+ >>> ep.attr
137
+ 'attr'
138
+ >>> ep.extras
139
+ ['extra1', 'extra2']
131
140
"""
132
141
133
142
pattern = re .compile (
@@ -176,7 +185,7 @@ def attr(self):
176
185
@property
177
186
def extras (self ):
178
187
match = self .pattern .match (self .value )
179
- return list ( re .finditer (r'\w+' , match .group ('extras' ) or '' ) )
188
+ return re .findall (r'\w+' , match .group ('extras' ) or '' )
180
189
181
190
def _for (self , dist ):
182
191
self .dist = dist
@@ -200,6 +209,25 @@ def __reduce__(self):
200
209
)
201
210
202
211
def matches (self , ** params ):
212
+ """
213
+ EntryPoint matches the given parameters.
214
+
215
+ >>> ep = EntryPoint(group='foo', name='bar', value='bing:bong [extra1, extra2]')
216
+ >>> ep.matches(group='foo')
217
+ True
218
+ >>> ep.matches(name='bar', value='bing:bong [extra1, extra2]')
219
+ True
220
+ >>> ep.matches(group='foo', name='other')
221
+ False
222
+ >>> ep.matches()
223
+ True
224
+ >>> ep.matches(extras=['extra1', 'extra2'])
225
+ True
226
+ >>> ep.matches(module='bing')
227
+ True
228
+ >>> ep.matches(attr='bong')
229
+ True
230
+ """
203
231
attrs = (getattr (self , param ) for param in params )
204
232
return all (map (operator .eq , params .values (), attrs ))
205
233
@@ -650,7 +678,7 @@ def _read_dist_info_reqs(self):
650
678
651
679
def _read_egg_info_reqs (self ):
652
680
source = self .read_text ('requires.txt' )
653
- return source and self ._deps_from_requires_text (source )
681
+ return None if source is None else self ._deps_from_requires_text (source )
654
682
655
683
@classmethod
656
684
def _deps_from_requires_text (cls , source ):
@@ -752,7 +780,6 @@ def __new__(cls, root):
752
780
753
781
def __init__ (self , root ):
754
782
self .root = root
755
- self .base = os .path .basename (self .root ).lower ()
756
783
757
784
def joinpath (self , child ):
758
785
return pathlib .Path (self .root , child )
0 commit comments