Add experimental support for lazy loading the info extractors

'make lazy-extractors' creates the youtube_dl/extractor/lazy_extractors.py (imported by youtube_dl/extractor/__init__.py), which contains simplified classes that only have the 'suitable' class method and that load the appropiate class with the '__new__' method when a instance is created.
This commit is contained in:
Jaime Marquínez Ferrándiz 2016-02-10 14:01:31 +01:00
parent 1b3d5e05a8
commit 779822d945
5 changed files with 99 additions and 8 deletions

View file

@ -0,0 +1,17 @@
# flake8: noqa
from __future__ import unicode_literals
import re
class LazyLoadExtractor(object):
_module = None
@classmethod
def ie_key(cls):
return cls.__name__[:-2]
def __new__(cls):
mod = __import__(cls._module, fromlist=(cls.__name__,))
real_cls = getattr(mod, cls.__name__)
return real_cls.__new__(real_cls)