# -*- coding: utf-8 -*-"""Module Descriptor=======================.. module:: pcapkit.corekit.module:mod:`pcapkit.corekit.module` contains :obj:`tuple`like class :class:`~pcapkit.corekit.module.ModuleDescriptor`,which is originally designed as :obj:`tuple[str, str] <tuple>`."""importcollectionsimportimportlibfromtypingimportTYPE_CHECKING,Generic,TypeVar__all__=['ModuleDescriptor']ifTYPE_CHECKING:fromtypingimportType_T=TypeVar('_T')
[docs]classModuleDescriptor(collections.namedtuple('ModuleDescriptor',['module','name']),Generic[_T]):"""Module descriptor contains module name and class name, the actual class can be imported by ``from module import name``."""__slots__=()#: Module name.module:str#: Class name.name:str@propertydefklass(self)->'Type[_T]':"""Import class from module."""module=importlib.import_module(self.module)returngetattr(module,self.name)