@@ -152,6 +152,15 @@ class EntryPoint(DeprecatedTuple):
152152 See `the packaging docs on entry points
153153 <https://packaging.python.org/specifications/entry-points/>`_
154154 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']
155164 """
156165
157166 pattern = re .compile (
@@ -203,7 +212,7 @@ def attr(self):
203212 @property
204213 def extras (self ):
205214 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 '' )
207216
208217 def _for (self , dist ):
209218 vars (self ).update (dist = dist )
@@ -221,6 +230,25 @@ def __iter__(self):
221230 return iter ((self .name , self ))
222231
223232 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+ """
224252 attrs = (getattr (self , param ) for param in params )
225253 return all (map (operator .eq , params .values (), attrs ))
226254
@@ -292,21 +320,15 @@ def wrapped(self, *args, **kwargs):
292320 self ._warn ()
293321 return getattr (super (), method_name )(* args , ** kwargs )
294322
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+ )
310332
311333 def __add__ (self , other ):
312334 if not isinstance (other , tuple ):
@@ -660,7 +682,7 @@ def _read_dist_info_reqs(self):
660682
661683 def _read_egg_info_reqs (self ):
662684 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 )
664686
665687 @classmethod
666688 def _deps_from_requires_text (cls , source ):
@@ -765,7 +787,6 @@ def __new__(cls, root):
765787
766788 def __init__ (self , root ):
767789 self .root = root
768- self .base = os .path .basename (self .root ).lower ()
769790
770791 def joinpath (self , child ):
771792 return pathlib .Path (self .root , child )
0 commit comments