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

23 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-18 17:27 +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__( 

36 self, auxdata: __.appcore.state.Globals 

37 ) -> None: 

38 ''' Executes command with global state. ''' 

39 raise NotImplementedError 

40 

41 @__.abc.abstractmethod 

42 def provide_configuration_edits( 

43 self, 

44 ) -> __.appcore.dictedits.Edits: 

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

46 raise NotImplementedError 

47 

48 

49class DifferencesDisplay( 

50 __.immut.DataclassProtocol, __.typx.Protocol, 

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

52): 

53 ''' Configuration for content differences display. ''' 

54 

55 context_lines: int = 3 

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

57 # TODO: colorize: bool = False 

58 # TODO: emojify: bool = False 

59 # TODO: show_whitespace: bool = False 

60 # TODO: truncate_lines: bool = False 

61 # TODO: wrap_lines: bool = False 

62 

63 @__.abc.abstractmethod 

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

65 ''' Displays differences segment. ''' 

66 raise NotImplementedError 

67 

68 

69class DifferencesInteractor( 

70 __.immut.DataclassProtocol, __.typx.Protocol, 

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

72): 

73 ''' Interactions with content differences. ''' 

74 

75 @__.abc.abstractmethod 

76 async def __call__( 

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

78 ) -> bool: 

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

80 raise NotImplementedError 

81 

82 

83class PartInteractor( 

84 __.immut.DataclassProtocol, __.typx.Protocol, 

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

86): 

87 ''' Interactions with mimeogram parts. ''' 

88 

89 @__.abc.abstractmethod 

90 async def __call__( 

91 self, target: _parts.Target 

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

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

94 raise NotImplementedError