Coverage for sources/mimeogram/interfaces.py: 78%

23 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-05 19:46 +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''' Abstract bases and interfaces. ''' 

22 

23 

24from . import __ 

25from . import parts as _parts 

26 

27 

28class CliCommand( 

29 __.immut.DataclassProtocol, __.typx.Protocol, 

30 decorators = ( __.typx.runtime_checkable, ), 

31): 

32 ''' CLI command. ''' 

33 

34 @__.abc.abstractmethod 

35 async def __call__( self, auxdata: __.Globals ) -> None: 

36 ''' Executes command with global state. ''' 

37 raise NotImplementedError 

38 

39 @__.abc.abstractmethod 

40 def provide_configuration_edits( self ) -> __.DictionaryEdits: 

41 ''' Provides edits against configuration from options. ''' 

42 raise NotImplementedError 

43 

44 

45class DifferencesDisplay( 

46 __.immut.DataclassProtocol, __.typx.Protocol, 

47 decorators = ( __.typx.runtime_checkable, ), 

48): 

49 ''' Configuration for content differences display. ''' 

50 

51 context_lines: int = 3 

52 inline_threshold: int = 24 # TODO? Adjust to terminal height. 

53 # TODO: colorize: bool = False 

54 # TODO: emojify: bool = False 

55 # TODO: show_whitespace: bool = False 

56 # TODO: truncate_lines: bool = False 

57 # TODO: wrap_lines: bool = False 

58 

59 @__.abc.abstractmethod 

60 async def __call__( self, lines: __.cabc.Sequence[ str ] ) -> None: 

61 ''' Displays differences segment. ''' 

62 raise NotImplementedError 

63 

64 

65class DifferencesInteractor( 

66 __.immut.DataclassProtocol, __.typx.Protocol, 

67 decorators = ( __.typx.runtime_checkable, ), 

68): 

69 ''' Interactions with content differences. ''' 

70 

71 @__.abc.abstractmethod 

72 async def __call__( 

73 self, lines: __.cabc.Sequence[ str ], display: DifferencesDisplay 

74 ) -> bool: 

75 ''' Prompts for action on differences segment. ''' 

76 raise NotImplementedError 

77 

78 

79class PartInteractor( 

80 __.immut.DataclassProtocol, __.typx.Protocol, 

81 decorators = ( __.typx.runtime_checkable, ), 

82): 

83 ''' Interactions with mimeogram parts. ''' 

84 

85 @__.abc.abstractmethod 

86 async def __call__( 

87 self, target: _parts.Target 

88 ) -> tuple[ _parts.Resolutions, str ]: 

89 ''' Prompts for action on mimeogram part. ''' 

90 raise NotImplementedError