@@ -152,6 +152,15 @@ class EntryPoint(DeprecatedTuple):
152
152
See `the packaging docs on entry points
153
153
<https://packaging.python.org/specifications/entry-points/>`_
154
154
for more information.
155
+
156
+ >>> ep = EntryPoint(
157
+ ... name=None, group=None, value='package.module:attr [extra1, extra2]')
158
+ >>> ep.module
159
+ 'package.module'
160
+ >>> ep.attr
161
+ 'attr'
162
+ >>> ep.extras
163
+ ['extra1', 'extra2']
155
164
"""
156
165
157
166
pattern = re .compile (
@@ -203,7 +212,7 @@ def attr(self):
203
212
@property
204
213
def extras (self ):
205
214
match = self .pattern .match (self .value )
206
- return list ( re .finditer (r'\w+' , match .group ('extras' ) or '' ) )
215
+ return re .findall (r'\w+' , match .group ('extras' ) or '' )
207
216
208
217
def _for (self , dist ):
209
218
vars (self ).update (dist = dist )
@@ -221,6 +230,25 @@ def __iter__(self):
221
230
return iter ((self .name , self ))
222
231
223
232
def matches (self , ** params ):
233
+ """
234
+ EntryPoint matches the given parameters.
235
+
236
+ >>> ep = EntryPoint(group='foo', name='bar', value='bing:bong [extra1, extra2]')
237
+ >>> ep.matches(group='foo')
238
+ True
239
+ >>> ep.matches(name='bar', value='bing:bong [extra1, extra2]')
240
+ True
241
+ >>> ep.matches(group='foo', name='other')
242
+ False
243
+ >>> ep.matches()
244
+ True
245
+ >>> ep.matches(extras=['extra1', 'extra2'])
246
+ True
247
+ >>> ep.matches(module='bing')
248
+ True
249
+ >>> ep.matches(attr='bong')
250
+ True
251
+ """
224
252
attrs = (getattr (self , param ) for param in params )
225
253
return all (map (operator .eq , params .values (), attrs ))
226
254
@@ -292,21 +320,15 @@ def wrapped(self, *args, **kwargs):
292
320
self ._warn ()
293
321
return getattr (super (), method_name )(* args , ** kwargs )
294
322
295
- return wrapped
296
-
297
- for method_name in [
298
- '__setitem__' ,
299
- '__delitem__' ,
300
- 'append' ,
301
- 'reverse' ,
302
- 'extend' ,
303
- 'pop' ,
304
- 'remove' ,
305
- '__iadd__' ,
306
- 'insert' ,
307
- 'sort' ,
308
- ]:
309
- locals ()[method_name ] = _wrap_deprecated_method (method_name )
323
+ return method_name , wrapped
324
+
325
+ locals ().update (
326
+ map (
327
+ _wrap_deprecated_method ,
328
+ '__setitem__ __delitem__ append reverse extend pop remove '
329
+ '__iadd__ insert sort' .split (),
330
+ )
331
+ )
310
332
311
333
def __add__ (self , other ):
312
334
if not isinstance (other , tuple ):
@@ -660,7 +682,7 @@ def _read_dist_info_reqs(self):
660
682
661
683
def _read_egg_info_reqs (self ):
662
684
source = self .read_text ('requires.txt' )
663
- return source and self ._deps_from_requires_text (source )
685
+ return pass_none ( self ._deps_from_requires_text ) (source )
664
686
665
687
@classmethod
666
688
def _deps_from_requires_text (cls , source ):
@@ -765,7 +787,6 @@ def __new__(cls, root):
765
787
766
788
def __init__ (self , root ):
767
789
self .root = root
768
- self .base = os .path .basename (self .root ).lower ()
769
790
770
791
def joinpath (self , child ):
771
792
return pathlib .Path (self .root , child )
0 commit comments