1+ """
2+ Display module for managing application output and presentation.
3+ Handles all display-related functionality with async support.
4+ """
5+
6+ import asyncio
7+ import helpers
8+
9+
10+ class DisplayModule :
11+ """Handles application display and output functionality."""
12+
13+ def __init__ (self ):
14+ """Initialize the display module."""
15+ pass
16+
17+ async def show_header (self ):
18+ """Display the application header."""
19+ print ("=== General Python Template ===" )
20+ print (f"Current time: { helpers .time ()} " )
21+ print ()
22+
23+ async def show_app_info (self ):
24+ """Display application information."""
25+ # Get basic app configuration
26+ app_name = helpers .get_config ('app.name' , 'Unknown App' )
27+ app_version = helpers .get_config ('app.version' , '0.0.0' )
28+ app_env = helpers .get_config ('app.env' , 'unknown' )
29+ app_debug = helpers .get_config ('app.debug' , False )
30+
31+ print (f"App: { app_name } v{ app_version } " )
32+ print (f"Environment: { app_env } (Debug: { app_debug } )" )
33+ print ()
34+
35+ async def show_app_response (self ):
36+ """Display the application response section."""
37+ response_number = helpers .get_config ('app.response_number' , 0 )
38+ message = helpers .get_config ('app.message' , 'Hello, World!' )
39+
40+ print ("=== App Response ===" )
41+ print (f"Message: { message } " )
42+ print (f"Response Number: { response_number } " )
43+ print ()
44+
45+ async def show_config_source (self ):
46+ """Display configuration source information."""
47+ response_number = helpers .get_config ('app.response_number' , 0 )
48+ message = helpers .get_config ('app.message' , 'Hello, World!' )
49+
50+ print ("=== Configuration Source ===" )
51+
52+ # Check response number source
53+ env_number = helpers .env ('APP_RESPONSE_NUMBER' )
54+ if env_number :
55+ print (f"Response number is overridden by environment variable: { env_number } " )
56+ else :
57+ print (f"Response number is from config file: { response_number } " )
58+
59+ # Check message source
60+ env_message = helpers .env ('APP_MESSAGE' )
61+ if env_message :
62+ print (f"Message is overridden by environment variable: { env_message } " )
63+ else :
64+ print (f"Message is from config file: { message } " )
65+
66+ async def show_all (self ):
67+ """Display all application information sections."""
68+ await self .show_header ()
69+ await self .show_app_info ()
70+ await self .show_app_response ()
71+ await self .show_config_source ()
72+
73+ async def show_with_delay (self , delay_seconds : float = 0.1 ):
74+ """
75+ Example of async functionality - show all sections with small delays.
76+ This demonstrates the async foundation in action.
77+ """
78+ await self .show_header ()
79+ await asyncio .sleep (delay_seconds )
80+
81+ await self .show_app_info ()
82+ await asyncio .sleep (delay_seconds )
83+
84+ await self .show_app_response ()
85+ await asyncio .sleep (delay_seconds )
86+
87+ await self .show_config_source ()
0 commit comments