Coverage for sources / ictr / standard / flavors.py: 100%
28 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-12 01:33 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-12 01:33 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
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#============================================================================#
21''' Standard flavors, flavor aliases, etc.... '''
24from . import __
25from . import compositors as _compositors
26from . import core as _core
27from . import introducers as _intros
30def produce_flavors(
31 introducercfg: _core.IntroducerConfiguration = (
32 _core.INTRODUCER_CONFIGURATION_DEFAULT ),
33 compositorcfg: _core.CompositorConfiguration = (
34 _core.COMPOSITOR_CONFIGURATION_DEFAULT ),
35) -> __.FlavorsRegistry:
36 ''' Produces registry of all standard flavors.
38 Customization of introducers and compositors is possible.
39 '''
40 flavors: __.FlavorsRegistryLiberal = { }
41 introducer = _intros.Introducer( configuration = introducercfg )
42 compositor = _compositors.Compositor(
43 configuration = compositorcfg, introducer = introducer )
44 for name, spec in __.flavor_specifications_standard.items( ):
45 ccfg = compositorcfg
46 if spec.stack:
47 lcfg = ccfg.linearizercfg
48 ecfg = __.dcls.replace(
49 lcfg.exceptionscfg,
50 enable_discovery = True,
51 enable_stacktraces = True )
52 lcfg = __.dcls.replace( lcfg, exceptionscfg = ecfg )
53 ccfg = __.dcls.replace( ccfg, linearizercfg = lcfg )
54 compositor = _compositors.Compositor(
55 configuration = ccfg, introducer = introducer )
56 flavors[ name ] = __.FlavorConfiguration(
57 compositor_factory = _produce_compositor_factory( compositor ) )
58 for alias, name in __.flavor_aliases_standard.items( ):
59 flavors[ alias ] = flavors[ name ]
60 for level in range( 10 ):
61 indent_i = ' ' * level
62 indent_s = ' ' * ( level + 1 )
63 ccfg = __.dcls.replace(
64 compositorcfg,
65 line_prefix_initial = indent_i,
66 line_prefix_subsequent = indent_s )
67 compositor = _compositors.Compositor(
68 configuration = ccfg, introducer = introducer )
69 flavors[ level ] = __.FlavorConfiguration(
70 compositor_factory = _produce_compositor_factory( compositor ) )
71 return __.immut.Dictionary( flavors )
74def _produce_compositor_factory(
75 compositor: _compositors.Compositor
76) -> __.CompositorFactory:
77 return lambda address, flavor: compositor