Coverage for sources/librovore/interfaces.py: 100%

34 statements  

« prev     ^ index     » next       coverage.py v7.10.5, created at 2025-08-29 01:14 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Common enumerations and interfaces. ''' 

22 

23 

24from . import __ 

25 

26 

27class FilterCapability( __.immut.DataclassObject ): 

28 ''' Describes a filter supported by a processor. ''' 

29 

30 name: str 

31 description: str 

32 type: str # "string", "enum", "boolean" 

33 values: __.typx.Optional[ list[ str ] ] = None # For enums 

34 required: bool = False 

35 

36 

37class DisplayFormat( __.enum.Enum ): 

38 ''' Enumeration for CLI display formats. ''' 

39 

40 JSON = 'json' 

41 Markdown = 'markdown' 

42 

43 

44class ProcessorGenera( __.enum.Enum ): 

45 ''' Enumeration for processor types/genera. ''' 

46 

47 Inventory = 'inventory' 

48 Structure = 'structure' 

49 

50 

51class InventoryQueryDetails( __.enum.IntFlag ): 

52 ''' Enumeration for inventory query detail levels. ''' 

53 

54 Name = 0 # Object names only (baseline) 

55 Signature = __.enum.auto( ) # Include signatures 

56 Summary = __.enum.auto( ) # Include brief descriptions 

57 Documentation = __.enum.auto( ) # Include full documentation 

58 

59 

60class MatchMode( str, __.enum.Enum ): 

61 ''' Enumeration for different term matching modes. ''' 

62 

63 Exact = 'exact' 

64 Regex = 'regex' 

65 Fuzzy = 'fuzzy' 

66 

67 

68class SearchBehaviors( __.immut.DataclassObject ): 

69 ''' Search behavior configuration for the search engine. ''' 

70 

71 match_mode: MatchMode = MatchMode.Fuzzy 

72 fuzzy_threshold: int = 50 

73 

74 

75_search_behaviors_default = SearchBehaviors( ) 

76_filters_default = __.immut.Dictionary[ str, __.typx.Any ]( ) 

77 

78 

79class ProcessorCapabilities( __.immut.DataclassObject ): 

80 ''' Complete capability description for a processor. ''' 

81 

82 processor_name: str 

83 version: str 

84 supported_filters: list[ FilterCapability ] 

85 results_limit_max: __.typx.Optional[ int ] = None 

86 response_time_typical: __.typx.Optional[ str ] = None # "fast", etc. 

87 notes: __.typx.Optional[ str ] = None