Coverage for src/qdrant_loader/connectors/base.py: 94%

17 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-04 05:50 +0000

1from abc import ABC, abstractmethod 

2 

3from qdrant_loader.config.source_config import SourceConfig 

4from qdrant_loader.core.document import Document 

5from qdrant_loader.core.file_conversion import FileConversionConfig 

6 

7 

8class BaseConnector(ABC): 

9 """Base class for all connectors.""" 

10 

11 def __init__(self, config: SourceConfig): 

12 self.config = config 

13 self._initialized = False 

14 

15 async def __aenter__(self): 

16 """Async context manager entry.""" 

17 self._initialized = True 

18 return self 

19 

20 async def __aexit__(self, exc_type, exc_val, exc_tb): 

21 """Async context manager exit.""" 

22 self._initialized = False 

23 

24 def set_file_conversion_config( 

25 self, file_conversion_config: FileConversionConfig 

26 ) -> None: 

27 """Set file conversion configuration. 

28 

29 This is a default implementation that does nothing. 

30 Subclasses that support file conversion should override this method. 

31 

32 Args: 

33 file_conversion_config: Global file conversion configuration 

34 """ 

35 pass 

36 

37 @abstractmethod 

38 async def get_documents(self) -> list[Document]: 

39 """Get documents from the source."""