2016-10-02 13:39:18 +02:00
|
|
|
# coding: utf-8
|
2016-02-10 14:01:31 +01:00
|
|
|
import re
|
|
|
|
|
|
|
|
|
2021-08-23 00:18:26 +02:00
|
|
|
class LazyLoadMetaClass(type):
|
|
|
|
def __getattr__(cls, name):
|
|
|
|
return getattr(cls._get_real_class(), name)
|
|
|
|
|
|
|
|
|
|
|
|
class LazyLoadExtractor(metaclass=LazyLoadMetaClass):
|
2016-02-10 14:01:31 +01:00
|
|
|
_module = None
|
2021-08-23 01:15:30 +02:00
|
|
|
_WORKING = True
|
2016-02-10 14:01:31 +01:00
|
|
|
|
2021-08-23 00:18:26 +02:00
|
|
|
@classmethod
|
|
|
|
def _get_real_class(cls):
|
|
|
|
if '__real_class' not in cls.__dict__:
|
|
|
|
mod = __import__(cls._module, fromlist=(cls.__name__,))
|
|
|
|
cls.__real_class = getattr(mod, cls.__name__)
|
|
|
|
return cls.__real_class
|
|
|
|
|
2016-02-21 12:46:14 +01:00
|
|
|
def __new__(cls, *args, **kwargs):
|
2021-08-23 00:18:26 +02:00
|
|
|
real_cls = cls._get_real_class()
|
2016-02-21 12:46:14 +01:00
|
|
|
instance = real_cls.__new__(real_cls)
|
|
|
|
instance.__init__(*args, **kwargs)
|
|
|
|
return instance
|