testing environment for extractor results

This commit is contained in:
Mike Fährmann
2015-12-12 15:58:07 +01:00
parent 9ca4426b72
commit 5304e5beef
2 changed files with 38 additions and 1 deletions

View File

@@ -52,13 +52,18 @@ modules = [
]
def find(url):
"""Find extractor suitable for handling the given url"""
"""Find suitable extractor for the given url"""
for pattern, klass in _list_patterns():
match = re.match(pattern, url)
if match:
return klass(match)
return None
def extractors():
"""Yield all available extractor classes"""
for _, klass in _list_patterns():
yield klass
# --------------------------------------------------------------------
# internals