Coverage for sources/emcdproj/__/preparation.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-05-27 21:05 +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''' Preparation of the library core. ''' 

22 

23 

24from . import imports as __ 

25from . import application as _application 

26# from . import configuration as _configuration 

27# from . import dictedits as _dictedits 

28from . import distribution as _distribution 

29# from . import environment as _environment 

30from . import state as _state 

31 

32 

33async def prepare( 

34 exits: __.ctxl.AsyncExitStack, 

35 application: _application.Information = ( 

36 _application.Information( ) ), # noqa: B008 

37 # configedits: _dictedits.Edits = ( ), 

38 # configfile: __.Absential[ __.Path ] = __.absent, 

39 # environment: bool = False, 

40) -> _state.Globals: 

41 ''' Prepares globals DTO for use with library functions. 

42 

43 Also: 

44 * Configures logging for library package (not application). 

45 * Optionally, loads process environment from files. 

46 

47 Note that asynchronous preparation allows for applications to 

48 concurrently initialize other entities outside of the library, even 

49 though the library initialization, itself, is inherently sequential. 

50 ''' 

51 directories = application.produce_platform_directories( ) 

52 distribution = ( 

53 await _distribution.Information.prepare( 

54 package = __.package_name, exits = exits ) ) 

55 # configuration = ( 

56 # await _configuration.acquire( 

57 # application_name = application.name, 

58 # directories = directories, 

59 # distribution = distribution, 

60 # edits = configedits, 

61 # file = configfile ) ) 

62 auxdata = _state.Globals( 

63 application = application, 

64 # configuration = configuration, 

65 directories = directories, 

66 distribution = distribution, 

67 exits = exits ) 

68 # if environment: await _environment.update( auxdata ) 

69 # _inscribe_preparation_report( auxdata ) 

70 return auxdata # noqa: RET504 

71 

72 

73# def _inscribe_preparation_report( auxdata: _state.Globals ): 

74# scribe = __.produce_scribe( __.package_name ) 

75# scribe.debug( f"Application Name: {auxdata.application.name}" ) 

76# # scribe.debug( f"Execution ID: {auxdata.application.execution_id}" ) 

77# scribe.debug( "Application Cache Location: {}".format( 

78# auxdata.provide_cache_location( ) ) ) 

79# scribe.debug( "Application Data Location: {}".format( 

80# auxdata.provide_data_location( ) ) ) 

81# scribe.debug( "Application State Location: {}".format( 

82# auxdata.provide_state_location( ) ) ) 

83# scribe.debug( "Package Data Location: {}".format( 

84# auxdata.distribution.provide_data_location( ) ) )