lazy_load_template.py (456B)
1 # coding: utf-8 2 from __future__ import unicode_literals 3 4 import re 5 6 7 class LazyLoadExtractor(object): 8 _module = None 9 10 @classmethod 11 def ie_key(cls): 12 return cls.__name__[:-2] 13 14 def __new__(cls, *args, **kwargs): 15 mod = __import__(cls._module, fromlist=(cls.__name__,)) 16 real_cls = getattr(mod, cls.__name__) 17 instance = real_cls.__new__(real_cls) 18 instance.__init__(*args, **kwargs) 19 return instance