LStartlet 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. lstartlet-0.1.0/.github/workflows/ci.yml +77 -0
  2. lstartlet-0.1.0/.gitignore +90 -0
  3. lstartlet-0.1.0/LICENSE +21 -0
  4. lstartlet-0.1.0/LStartlet.egg-info/PKG-INFO +492 -0
  5. lstartlet-0.1.0/LStartlet.egg-info/SOURCES.txt +95 -0
  6. lstartlet-0.1.0/LStartlet.egg-info/dependency_links.txt +1 -0
  7. lstartlet-0.1.0/LStartlet.egg-info/not-zip-safe +1 -0
  8. lstartlet-0.1.0/LStartlet.egg-info/requires.txt +2 -0
  9. lstartlet-0.1.0/LStartlet.egg-info/top_level.txt +2 -0
  10. lstartlet-0.1.0/MANIFEST.in +17 -0
  11. lstartlet-0.1.0/PKG-INFO +492 -0
  12. lstartlet-0.1.0/README.md +458 -0
  13. lstartlet-0.1.0/check-local.bat +29 -0
  14. lstartlet-0.1.0/core/__init__.py +256 -0
  15. lstartlet-0.1.0/core/cicd/__init__.py +21 -0
  16. lstartlet-0.1.0/core/cicd/builder.py +226 -0
  17. lstartlet-0.1.0/core/cicd/cicd_controller.py +375 -0
  18. lstartlet-0.1.0/core/cicd/dependency_installer.py +343 -0
  19. lstartlet-0.1.0/core/cicd/deployer.py +526 -0
  20. lstartlet-0.1.0/core/cicd/pipeline.py +120 -0
  21. lstartlet-0.1.0/core/cicd/tester.py +363 -0
  22. lstartlet-0.1.0/core/command/__init__.py +27 -0
  23. lstartlet-0.1.0/core/command/command_base.py +107 -0
  24. lstartlet-0.1.0/core/command/command_events.py +106 -0
  25. lstartlet-0.1.0/core/command/command_executor.py +192 -0
  26. lstartlet-0.1.0/core/command/command_registry.py +136 -0
  27. lstartlet-0.1.0/core/command/commands/__init__.py +3 -0
  28. lstartlet-0.1.0/core/command/commands/system_commands.py +136 -0
  29. lstartlet-0.1.0/core/config/__init__.py +98 -0
  30. lstartlet-0.1.0/core/config/config_item.py +53 -0
  31. lstartlet-0.1.0/core/config/config_manager.py +395 -0
  32. lstartlet-0.1.0/core/config/constants.py +25 -0
  33. lstartlet-0.1.0/core/config/utils.py +174 -0
  34. lstartlet-0.1.0/core/decorators.py +576 -0
  35. lstartlet-0.1.0/core/di/__init__.py +11 -0
  36. lstartlet-0.1.0/core/di/app_container.py +22 -0
  37. lstartlet-0.1.0/core/di/container_config.py +78 -0
  38. lstartlet-0.1.0/core/di/exceptions.py +63 -0
  39. lstartlet-0.1.0/core/di/service_container.py +233 -0
  40. lstartlet-0.1.0/core/di/service_descriptor.py +54 -0
  41. lstartlet-0.1.0/core/di/service_registry.py +25 -0
  42. lstartlet-0.1.0/core/error/__init__.py +49 -0
  43. lstartlet-0.1.0/core/error/error_handler.py +178 -0
  44. lstartlet-0.1.0/core/error/exceptions.py +56 -0
  45. lstartlet-0.1.0/core/error/formatter.py +77 -0
  46. lstartlet-0.1.0/core/event/__init__.py +24 -0
  47. lstartlet-0.1.0/core/event/base_event.py +109 -0
  48. lstartlet-0.1.0/core/event/event_bus.py +498 -0
  49. lstartlet-0.1.0/core/event/event_handler.py +172 -0
  50. lstartlet-0.1.0/core/event/event_interceptor.py +67 -0
  51. lstartlet-0.1.0/core/event/event_type_registry.py +133 -0
  52. lstartlet-0.1.0/core/event/events/scheduler_events.py +313 -0
  53. lstartlet-0.1.0/core/event/events/ui_events.py +94 -0
  54. lstartlet-0.1.0/core/logger/__init__.py +213 -0
  55. lstartlet-0.1.0/core/logger/handler.py +243 -0
  56. lstartlet-0.1.0/core/logger/level.py +25 -0
  57. lstartlet-0.1.0/core/logger/logger.py +227 -0
  58. lstartlet-0.1.0/core/path/__init__.py +109 -0
  59. lstartlet-0.1.0/core/path/constants.py +36 -0
  60. lstartlet-0.1.0/core/path/path_manager.py +113 -0
  61. lstartlet-0.1.0/core/path/utils.py +204 -0
  62. lstartlet-0.1.0/core/persistence/__init__.py +42 -0
  63. lstartlet-0.1.0/core/persistence/exceptions/persistence_exceptions.py +43 -0
  64. lstartlet-0.1.0/core/persistence/models/persistence_models.py +47 -0
  65. lstartlet-0.1.0/core/persistence/persistence_manager.py +196 -0
  66. lstartlet-0.1.0/core/persistence/storage/kv_storage.py +267 -0
  67. lstartlet-0.1.0/core/process/__init__.py +7 -0
  68. lstartlet-0.1.0/core/process/process_manager.py +342 -0
  69. lstartlet-0.1.0/core/scheduler/__init__.py +25 -0
  70. lstartlet-0.1.0/core/scheduler/config_manager.py +136 -0
  71. lstartlet-0.1.0/core/scheduler/process_manager.py +200 -0
  72. lstartlet-0.1.0/core/scheduler/scheduler.py +392 -0
  73. lstartlet-0.1.0/core/scheduler/scheduler_factory.py +84 -0
  74. lstartlet-0.1.0/core/scheduler/simple_thread_scheduler.py +92 -0
  75. lstartlet-0.1.0/core/scheduler/task_dispatcher.py +377 -0
  76. lstartlet-0.1.0/core/scheduler/thread_safe_scheduler.py +176 -0
  77. lstartlet-0.1.0/core/scheduler/tick.py +299 -0
  78. lstartlet-0.1.0/core/system/__init__.py +8 -0
  79. lstartlet-0.1.0/core/system/config_manager.py +243 -0
  80. lstartlet-0.1.0/core/system/system_detector.py +356 -0
  81. lstartlet-0.1.0/core/version_control/__init__.py +17 -0
  82. lstartlet-0.1.0/core/version_control/dependency_resolver.py +291 -0
  83. lstartlet-0.1.0/core/version_control/version_controller.py +299 -0
  84. lstartlet-0.1.0/plugin/__init__.py +46 -0
  85. lstartlet-0.1.0/plugin/base/plugin_base.py +224 -0
  86. lstartlet-0.1.0/plugin/base/plugin_interface.py +94 -0
  87. lstartlet-0.1.0/plugin/events/plugin_events.py +128 -0
  88. lstartlet-0.1.0/plugin/exceptions/plugin_exceptions.py +60 -0
  89. lstartlet-0.1.0/plugin/manager/dependency_manager.py +368 -0
  90. lstartlet-0.1.0/plugin/manager/plugin_loader.py +257 -0
  91. lstartlet-0.1.0/plugin/manager/plugin_manager.py +454 -0
  92. lstartlet-0.1.0/plugin/metadata.py +239 -0
  93. lstartlet-0.1.0/pyproject.toml +40 -0
  94. lstartlet-0.1.0/requirements-dev.txt +9 -0
  95. lstartlet-0.1.0/requirements.txt +2 -0
  96. lstartlet-0.1.0/setup.cfg +4 -0
  97. lstartlet-0.1.0/setup.py +52 -0
@@ -0,0 +1,77 @@
1
+ name: CI/CD Pipeline
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, master ]
6
+ pull_request:
7
+ branches: [ main, master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: windows-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.8", "3.9", "3.10", "3.11"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install system dependencies
25
+ run: |
26
+ # Install Microsoft Visual C++ Build Tools for Windows
27
+ choco install visualcpp-build-tools -y
28
+
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install -r requirements.txt
33
+ pip install -r requirements-dev.txt
34
+
35
+ # Install common libraries for testing
36
+ pip install numpy scipy pandas
37
+ pip install opencv-python pillow scikit-image
38
+
39
+ - name: Run tests
40
+ run: |
41
+ python tests/run_tests.py
42
+
43
+ - name: Run code formatting check
44
+ continue-on-error: true
45
+ run: |
46
+ python -m black --check --fast . --diff
47
+
48
+ - name: Run type checking
49
+ continue-on-error: true
50
+ if: matrix.python-version == '3.9' # Only run type checking on Python 3.9 to save time
51
+ run: |
52
+ python -m mypy core plugin tests --ignore-missing-imports
53
+
54
+ build:
55
+ needs: test
56
+ runs-on: windows-latest
57
+ steps:
58
+ - uses: actions/checkout@v3
59
+
60
+ - name: Set up Python
61
+ uses: actions/setup-python@v4
62
+ with:
63
+ python-version: "3.9"
64
+
65
+ - name: Install dependencies
66
+ run: |
67
+ python -m pip install --upgrade pip
68
+ pip install -r requirements.txt
69
+ pip install build twine wheel setuptools
70
+
71
+ - name: Build package
72
+ run: |
73
+ python -m build
74
+
75
+ - name: Check package metadata
76
+ run: |
77
+ twine check dist/*
@@ -0,0 +1,90 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ *.egg-info/
19
+ .installed.cfg
20
+ *.egg
21
+
22
+ # Virtual Environment
23
+ venv/
24
+ ENV/
25
+ .env
26
+ .venv
27
+ env.bak/
28
+ venv.bak/
29
+
30
+ # IDE
31
+ .vscode/
32
+ .idea/
33
+ *.swp
34
+ *.swo
35
+ *~
36
+ .*.swp
37
+ .*.swo
38
+
39
+ # Logs and databases
40
+ *.log
41
+ logs/
42
+ log/
43
+ *.sqlite3
44
+
45
+ # Testing
46
+ .pytest_cache/
47
+ .test-reports/
48
+ .coverage
49
+ coverage.xml
50
+ htmlcov/
51
+ .mypy_cache/
52
+
53
+ # Build artifacts
54
+ *.whl
55
+ *.tar.gz
56
+
57
+ # Configuration files
58
+ # 用户配置文件 - 不应提交到版本控制
59
+ config.yaml
60
+ config.json
61
+ user_config.yaml
62
+ user_config.json
63
+ system_config.yaml
64
+ system_config.yaml.backup
65
+ *.local.yaml
66
+ *.local.json
67
+ .local/
68
+
69
+ # 排除任何包含config的yaml/json文件
70
+ *config*.yaml
71
+ *config*.json
72
+
73
+ # 注意:系统配置文件(如 config.system.yaml, default.config 等)将被追踪
74
+ # 如需忽略特定系统配置文件,请单独添加规则
75
+
76
+ # 临时文件
77
+ *.tmp
78
+ *.temp
79
+ temp/
80
+ output/
81
+
82
+ # Data directories
83
+ data/
84
+
85
+ # Windows specific
86
+ Thumbs.db
87
+ ehthumbs.db
88
+ Desktop.ini
89
+ $RECYCLE.BIN/
90
+ /deployment/*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wwkkyy0325
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,492 @@
1
+ Metadata-Version: 2.4
2
+ Name: LStartlet
3
+ Version: 0.1.0
4
+ Summary: A modular, high-cohesion, low-coupling infrastructure framework for Python applications
5
+ Home-page: https://github.com/wwkkyy0325/LStartlet
6
+ Author: wwkkyy0325
7
+ Author-email: 1074446976@qq.com
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
+ Requires-Python: >=3.8, <3.13
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: PyYAML>=6.0
23
+ Requires-Dist: psutil>=5.9.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license-file
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # LStartlet
36
+
37
+ A modular, high-cohesion, low-coupling infrastructure framework for Python applications.
38
+
39
+ ## Project Overview
40
+
41
+ This project provides a comprehensive foundation for building robust Python applications with standardized components for configuration management, dependency injection, event handling, logging, and more. It's designed as a pure scaffolding framework without any domain-specific code.
42
+
43
+ ## Core Components
44
+
45
+ ### Configuration Management ([core.config](file:///f:/workspace-new/python/ocr/core/config/__init__.py#L0-L174))
46
+ - Unified configuration access and management
47
+ - Type-safe configuration registration
48
+ - Validation and change listeners
49
+ - File-based persistence
50
+
51
+ ## Configuration Management
52
+
53
+ This framework provides a comprehensive configuration management system with the following features:
54
+
55
+ ### Main Configuration Files
56
+
57
+ 1. **`system_config.yaml`** (Protected)
58
+ - Automatically maintained by the system
59
+ - Contains hardware detection results and environment information
60
+ - **Users should NOT modify this file**
61
+ - Changes will be overwritten by system updates
62
+
63
+ 2. **`config.yaml`** (User-modifiable)
64
+ - Contains application settings that users can customize
65
+ - Will not be overwritten by system updates
66
+ - Supports all application configuration options
67
+
68
+ ### Plugin Configuration
69
+
70
+ - Each plugin maintains its own `config.yaml` file in its directory
71
+ - Plugin configurations are automatically wrapped in their namespace
72
+ - Access plugin config using dotted notation: `plugin_namespace.setting_name`
73
+
74
+ ### Configuration Access Examples
75
+
76
+ ```python
77
+ from core.config import get_config, get_config_manager
78
+
79
+ # Get main application config
80
+ app_name = get_config('app.name')
81
+ debug_mode = get_config('app.debug_mode', False)
82
+
83
+ # Get plugin config
84
+ plugin_setting = get_config('com.example.myplugin.settings.enabled')
85
+
86
+ # Check if config is protected (from system_config)
87
+ config_manager = get_config_manager()
88
+ is_protected = config_manager.is_protected('system.platform')
89
+
90
+ # List all plugin namespaces
91
+ plugin_namespaces = config_manager.list_namespaces()
92
+ ```
93
+
94
+ ### Configuration Hierarchy
95
+
96
+ The configuration loading follows this priority order:
97
+ 1. **System Config** (`system_config.yaml`) - Highest priority, protected
98
+ 2. **User Config** (`config.yaml`) - Medium priority, user-modifiable
99
+ 3. **Plugin Config** (`plugin/*/config.yaml`) - Wrapped in namespace
100
+ 4. **Default Values** - Lowest priority, built-in defaults
101
+
102
+ ### Best Practices
103
+
104
+ - Never modify `system_config.yaml` manually
105
+ - Use `config.yaml` for all user customizations
106
+ - Plugin developers should use unique namespace prefixes (e.g., `com.company.pluginname`)
107
+ - Always provide default values when accessing configuration to handle missing keys gracefully
108
+
109
+ ### Dependency Injection ([core.di](file:///f:/workspace-new/python/ocr/core/di/service_container.py#L0-L174))
110
+ - Service container with singleton/transient/scoped lifetimes
111
+ - Automatic dependency resolution
112
+ - Circular dependency detection
113
+
114
+ ### Event System ([core.event](file:///f:/workspace-new/python/ocr/core/event/event_bus.py#L0-L111))
115
+ - Thread-safe event bus
116
+ - Publish/subscribe pattern
117
+ - Event type registry
118
+ - Async event support
119
+
120
+ ### Logging System ([core.logger](file:///f:/workspace-new/python/ocr/core/logger/logger.py#L0-L241))
121
+ - Multi-level logging (DEBUG, INFO, WARNING, ERROR, CRITICAL)
122
+ - Console and file handlers
123
+ - Caller-aware logging (shows actual calling file/line)
124
+ - Structured logging with extra context
125
+
126
+ ### Command System ([core.command](file:///f:/workspace-new/python/ocr/core/command/command_base.py#L0-L44))
127
+ - Command pattern implementation
128
+ - Command execution tracking
129
+ - Event-driven command lifecycle
130
+
131
+ ### Scheduler ([core.scheduler](file:///f:/workspace-new/python/ocr/core/scheduler/scheduler.py#L0-L244))
132
+ - Process and task management
133
+ - Configurable scheduling
134
+ - Async task support
135
+ - Health monitoring
136
+
137
+ ### Path Management ([core.path](file:///f:/workspace-new/python/ocr/core/path/path_manager.py#L0-L49))
138
+ - Unified path access
139
+ - Project structure awareness
140
+ - Cross-platform path handling
141
+
142
+ ### Persistence ([core.persistence](file:///f:/workspace-new/python/ocr/core/persistence/persistence_manager.py#L0-L35))
143
+ - Data storage and retrieval
144
+ - Multiple storage backends
145
+ - Transaction support
146
+
147
+ ### Error Handling ([core.error](file:///f:/workspace-new/python/ocr/core/error/error_handler.py#L0-L78))
148
+ - Unified error handling
149
+ - Global exception catching
150
+ - Structured error formatting
151
+ - Context-aware error logging
152
+
153
+ ### Plugin System ([plugin](file:///f:/workspace-new/python/ocr/plugin/manager/plugin_manager.py#L0-L111))
154
+ - Extensible plugin architecture
155
+ - Dynamic plugin loading
156
+ - Plugin lifecycle management
157
+
158
+ ### Version Control ([core.version_control](file:///f:/workspace-new/python/ocr/core/version_control/version_controller.py#L0-L244))
159
+ - Version management and tagging
160
+ - Incremental package generation
161
+ - Dependency analysis and management
162
+ - Change tracking and reporting
163
+
164
+ ### CI/CD Pipeline ([core.cicd](file:///f:/workspace-new/python/ocr/core/cicd/cicd_controller.py#L0-L244))
165
+ - Continuous integration and deployment automation
166
+ - Build, test, and deployment orchestration
167
+ - Pipeline definition and execution
168
+ - Deployment history and rollback
169
+
170
+ ## Usage Examples
171
+
172
+ ### Configuration
173
+ ```python
174
+ from core.config import get_config, set_config, register_config
175
+
176
+ # Register a new config
177
+ register_config("my_setting", "default_value", str, "My custom setting")
178
+
179
+ # Get config value
180
+ value = get_config("my_setting")
181
+
182
+ # Set config value
183
+ set_config("my_setting", "new_value")
184
+
185
+ # Listen for config changes
186
+ def my_listener(key, old_value, new_value):
187
+ print(f"Config {key} changed from {old_value} to {new_value}")
188
+
189
+ add_config_listener(my_listener)
190
+ set_config("my_setting", "another_value") # Will trigger listener
191
+
192
+ # Save/load configs to/from file
193
+ save_config("my_settings.yaml") # Save current configs
194
+ load_config("my_settings.yaml") # Load configs from file
195
+ ```
196
+
197
+ ### Logging
198
+ ```python
199
+ from core.logger import info, debug, warning, error
200
+
201
+ info("This is an info message")
202
+ debug("Debug information")
203
+ warning("This is a warning")
204
+ error("An error occurred")
205
+
206
+ # Structured logging with extra context
207
+ info("User login attempt", extra={
208
+ "user_id": 12345,
209
+ "ip_address": "192.168.1.1",
210
+ "success": True
211
+ })
212
+ ```
213
+
214
+ ### Dependency Injection
215
+ ```python
216
+ from core.di import get_default_container
217
+
218
+ # Define an interface和服务
219
+ class DatabaseInterface:
220
+ def save(self, data): pass
221
+
222
+ class MySQLDatabase(DatabaseInterface):
223
+ def __init__(self, host: str, port: int):
224
+ self.host = host
225
+ self.port = port
226
+
227
+ def save(self, data):
228
+ print(f"Saving {data} to MySQL at {self.host}:{self.port}")
229
+
230
+ # Register a service with the container
231
+ container = get_default_container()
232
+ container.register(DatabaseInterface, MySQLDatabase, host="localhost", port=3306)
233
+
234
+ # Resolve the service
235
+ database = container.resolve(DatabaseInterface)
236
+ database.save("some data") # Output: Saving some data to MySQL at localhost:3306
237
+ ```
238
+
239
+ ### Events
240
+ ```python
241
+ from core.event import event_bus, BaseEvent
242
+
243
+ class MyEvent(BaseEvent):
244
+ def __init__(self, data):
245
+ self.data = data
246
+
247
+ # Subscribe to events
248
+ def handle_event(event):
249
+ print(f"Received event: {event.data}")
250
+
251
+ event_bus.subscribe(MyEvent, handle_event)
252
+
253
+ # Publish event
254
+ event_bus.publish(MyEvent("test data")) # Output: Received event: test data
255
+ ```
256
+
257
+ ### Scheduler
258
+ ```python
259
+ from core.scheduler import Scheduler
260
+ from core.scheduler.config_manager import SchedulerConfig
261
+
262
+ # Create scheduler with custom config
263
+ config = SchedulerConfig(
264
+ max_processes=6,
265
+ process_timeout=45.0,
266
+ max_concurrent_tasks=15,
267
+ scheduling_strategy="priority"
268
+ )
269
+
270
+ scheduler = Scheduler(config)
271
+
272
+ # Start the scheduler
273
+ scheduler.start()
274
+
275
+ # Submit a task (example)
276
+ def sample_task():
277
+ print("Executing scheduled task")
278
+ return "Task completed"
279
+
280
+ # Stop the scheduler
281
+ scheduler.stop()
282
+ ```
283
+
284
+ ### Path Management
285
+ ```python
286
+ from core.path import get_project_root, get_data_dir, join_path
287
+
288
+ # Get common paths
289
+ project_root = get_project_root()
290
+ data_dir = get_data_dir()
291
+
292
+ # Join paths safely across platforms
293
+ config_path = join_path(get_project_root(), "config", "app_config.yaml")
294
+ ```
295
+
296
+ ### Plugin System
297
+ ```python
298
+ from plugin.manager.plugin_manager import PluginManager
299
+ from plugin.base.plugin_interface import PluginInterface
300
+
301
+ # Create a simple plugin
302
+ class MyPlugin(PluginInterface):
303
+ def __init__(self):
304
+ super().__init__()
305
+ self.name = "MyPlugin"
306
+ self.version = "1.0.0"
307
+
308
+ def activate(self):
309
+ print(f"{self.name} activated")
310
+
311
+ def deactivate(self):
312
+ print(f"{self.name} deactivated")
313
+
314
+ # Use plugin manager
315
+ plugin_manager = PluginManager()
316
+ plugin_manager.load_plugin(MyPlugin())
317
+ plugin_manager.activate_plugin("MyPlugin")
318
+ ```
319
+
320
+ ### Version Control
321
+ ```python
322
+ from core.version_control import VersionController
323
+
324
+ # Create version controller instance
325
+ vc = VersionController()
326
+
327
+ # Get current version
328
+ current_version = vc.get_current_version()
329
+ print(f"Current version: {current_version}")
330
+
331
+ # Create a new tag
332
+ vc.create_tag("v1.0.1", "Release version 1.0.1")
333
+
334
+ # Generate incremental package between two versions
335
+ package_path = vc.generate_incremental_package("v1.0.0", "v1.0.1")
336
+ if package_path:
337
+ print(f"Incremental package generated: {package_path}")
338
+
339
+ # Analyze dependencies
340
+ from core.version_control import DependencyResolver
341
+ resolver = DependencyResolver()
342
+ external_deps = resolver.get_external_dependencies()
343
+ print(f"External dependencies: {external_deps}")
344
+
345
+ # Generate requirements.txt based on code analysis
346
+ resolver.generate_requirements_txt("requirements_new.txt")
347
+ ```
348
+
349
+ ### CI/CD Pipeline
350
+ ```python
351
+ from core.cicd import CICDController, Pipeline, Stage, Step
352
+
353
+ # Create CI/CD controller
354
+ cicd = CICDController()
355
+
356
+ # Define a simple pipeline
357
+ pipeline = Pipeline("main-pipeline", "Main CI/CD pipeline for the application")
358
+
359
+ # Create stages
360
+ build_stage = Stage("build", "Build the application")
361
+ test_stage = Stage("test", "Run tests")
362
+ deploy_stage = Stage("deploy", "Deploy to environment")
363
+
364
+ # Add steps to build stage
365
+ def run_build():
366
+ return cicd.builder.build()
367
+
368
+ build_step = Step("build-app", run_build, "Build the application")
369
+ build_stage.add_step(build_step)
370
+
371
+ # Add steps to test stage
372
+ def run_tests():
373
+ results = cicd.tester.run_tests()
374
+ return results['passed'] > 0 and results['errors'] == 0 and results['failures'] == 0
375
+
376
+ test_step = Step("run-unit-tests", run_tests, "Run unit tests")
377
+ test_stage.add_step(test_step)
378
+
379
+ # Add steps to deploy stage
380
+ def run_deploy():
381
+ return cicd.deployer.deploy("staging")
382
+
383
+ deploy_step = Step("deploy-staging", run_deploy, "Deploy to staging environment")
384
+ deploy_stage.add_step(deploy_step)
385
+
386
+ # Add stages to pipeline
387
+ pipeline.add_stages([build_stage, test_stage, deploy_stage])
388
+
389
+ # Run the pipeline
390
+ success = cicd.run_pipeline(pipeline, version_tag="v1.0.2", deploy_target="staging")
391
+ if success:
392
+ print("Pipeline executed successfully!")
393
+ else:
394
+ print("Pipeline failed!")
395
+ ```
396
+
397
+ ## Advanced Examples
398
+
399
+ ### Using Dependency Injection with Events and Configuration
400
+ ```python
401
+ from core.di import get_default_container
402
+ from core.config import get_config
403
+ from core.event import event_bus, BaseEvent
404
+
405
+ class TaskCompletedEvent(BaseEvent):
406
+ def __init__(self, task_id: str, result: str):
407
+ self.task_id = task_id
408
+ self.result = result
409
+
410
+ class TaskProcessor:
411
+ def __init__(self):
412
+ self.max_retries = get_config("max_task_retries", 3)
413
+
414
+ def process_task(self, task_id: str):
415
+ # Simulate task processing
416
+ result = f"Processed task {task_id}"
417
+
418
+ # Publish event when task completes
419
+ event_bus.publish(TaskCompletedEvent(task_id, result))
420
+ return result
421
+
422
+ # Register and use the service
423
+ container = get_default_container()
424
+ container.register(TaskProcessor, TaskProcessor)
425
+
426
+ # Subscribe to events
427
+ def on_task_completed(event):
428
+ print(f"Task {event.task_id} completed with result: {event.result}")
429
+
430
+ event_bus.subscribe(TaskCompletedEvent, on_task_completed)
431
+
432
+ # Use the processor
433
+ processor = container.resolve(TaskProcessor)
434
+ processor.process_task("123")
435
+ ```
436
+
437
+ ### Comprehensive Error Handling
438
+ ```python
439
+ from core.error import handle_error
440
+ from core.logger import error as log_error
441
+
442
+ try:
443
+ # Some risky operation
444
+ risky_operation_result = perform_risky_operation()
445
+ except Exception as e:
446
+ # Handle error with context
447
+ handle_error(e)
448
+ log_error(f"Operation failed: {str(e)}", extra={
449
+ "operation_type": "risky_operation",
450
+ "context": "during processing"
451
+ })
452
+ ```
453
+
454
+ ## Testing
455
+
456
+ Run all tests:
457
+ ```bash
458
+ python tests/run_tests.py
459
+ ```
460
+
461
+ ## Requirements
462
+
463
+ - Python 3.9 (optimized for Windows platform)
464
+ - psutil
465
+ - PyYAML
466
+
467
+ ### Installation
468
+
469
+ Install core dependencies:
470
+ ```bash
471
+ pip install -r requirements.txt
472
+ ```
473
+
474
+ ### Windows-Specific Notes
475
+
476
+ - Fully tested and optimized for Windows platforms
477
+ - Includes proper handling for Windows file paths and process management
478
+ - Compatible with Windows Subsystem for Linux (WSL) if needed
479
+
480
+ ## Contributing
481
+
482
+ 1. Fork the repository
483
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
484
+ 3. Make your changes
485
+ 4. Run the tests (`python tests/run_tests.py`)
486
+ 5. Commit your changes (`git commit -m 'Add amazing feature'`)
487
+ 6. Push to the branch (`git push origin feature/amazing-feature`)
488
+ 7. Open a Pull Request
489
+
490
+ ## License
491
+
492
+ This project is licensed under the MIT License - see the [LICENSE](file:///f:/workspace-new/python/ocr/LICENSE) file for details.