12 # These bloat the lazy_extractors, so allow them to passthrough silently
13 ALLOWED_CLASSMETHODS
= {'extract_from_webpage', 'get_testcases', 'get_webpage_testcases'}
17 class LazyLoadMetaClass(type):
18 def __getattr__(cls
, name
):
20 if ('_real_class' not in cls
.__dict
__
21 and name
not in ALLOWED_CLASSMETHODS
and not _WARNED
):
23 write_string('WARNING: Falling back to normal extractor since lazy extractor '
24 f
'{cls.__name__} does not have attribute {name}{bug_reports_message()}\n')
25 return getattr(cls
.real_class
, name
)
28 class LazyLoadExtractor(metaclass
=LazyLoadMetaClass
):
31 if '_real_class' not in cls
.__dict
__:
32 cls
._real
_class
= getattr(importlib
.import_module(cls
._module
), cls
.__name
__)
33 return cls
._real
_class
35 def __new__(cls
, *args
, **kwargs
):
36 instance
= cls
.real_class
.__new
__(cls
.real_class
)
37 instance
.__init
__(*args
, **kwargs
)