exonware-xwsystem 0.1.0.1__py3-none-any.whl → 0.1.0.3__py3-none-any.whl
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.
- exonware/__init__.py +2 -1
- exonware/conf.py +2 -2
- exonware/xwsystem/__init__.py +115 -43
- exonware/xwsystem/base.py +30 -0
- exonware/xwsystem/caching/__init__.py +39 -13
- exonware/xwsystem/caching/base.py +24 -6
- exonware/xwsystem/caching/bloom_cache.py +2 -2
- exonware/xwsystem/caching/cache_manager.py +2 -1
- exonware/xwsystem/caching/conditional.py +2 -2
- exonware/xwsystem/caching/contracts.py +85 -139
- exonware/xwsystem/caching/decorators.py +6 -19
- exonware/xwsystem/caching/defs.py +2 -1
- exonware/xwsystem/caching/disk_cache.py +2 -1
- exonware/xwsystem/caching/distributed.py +2 -1
- exonware/xwsystem/caching/errors.py +2 -1
- exonware/xwsystem/caching/events.py +110 -27
- exonware/xwsystem/caching/eviction_strategies.py +2 -2
- exonware/xwsystem/caching/external_caching_python.py +701 -0
- exonware/xwsystem/caching/facade.py +253 -0
- exonware/xwsystem/caching/factory.py +300 -0
- exonware/xwsystem/caching/fluent.py +14 -12
- exonware/xwsystem/caching/integrity.py +21 -6
- exonware/xwsystem/caching/lfu_cache.py +2 -1
- exonware/xwsystem/caching/lfu_optimized.py +18 -6
- exonware/xwsystem/caching/lru_cache.py +7 -4
- exonware/xwsystem/caching/memory_bounded.py +2 -2
- exonware/xwsystem/caching/metrics_exporter.py +2 -2
- exonware/xwsystem/caching/observable_cache.py +2 -2
- exonware/xwsystem/caching/pluggable_cache.py +2 -2
- exonware/xwsystem/caching/rate_limiter.py +2 -2
- exonware/xwsystem/caching/read_through.py +2 -2
- exonware/xwsystem/caching/secure_cache.py +81 -28
- exonware/xwsystem/caching/serializable.py +9 -7
- exonware/xwsystem/caching/stats.py +2 -2
- exonware/xwsystem/caching/tagging.py +2 -2
- exonware/xwsystem/caching/ttl_cache.py +4 -3
- exonware/xwsystem/caching/two_tier_cache.py +6 -3
- exonware/xwsystem/caching/utils.py +30 -12
- exonware/xwsystem/caching/validation.py +2 -2
- exonware/xwsystem/caching/warming.py +6 -3
- exonware/xwsystem/caching/write_behind.py +15 -6
- exonware/xwsystem/config/__init__.py +11 -17
- exonware/xwsystem/config/base.py +5 -5
- exonware/xwsystem/config/contracts.py +93 -153
- exonware/xwsystem/config/defaults.py +3 -2
- exonware/xwsystem/config/defs.py +3 -2
- exonware/xwsystem/config/errors.py +2 -5
- exonware/xwsystem/config/logging.py +12 -8
- exonware/xwsystem/config/logging_setup.py +3 -2
- exonware/xwsystem/config/performance.py +1 -46
- exonware/xwsystem/config/performance_modes.py +9 -8
- exonware/xwsystem/config/version_manager.py +1 -0
- exonware/xwsystem/config.py +27 -0
- exonware/xwsystem/console/__init__.py +53 -0
- exonware/xwsystem/console/base.py +133 -0
- exonware/xwsystem/console/cli/__init__.py +61 -0
- exonware/xwsystem/{cli → console/cli}/args.py +27 -24
- exonware/xwsystem/{cli → console/cli}/base.py +18 -87
- exonware/xwsystem/{cli → console/cli}/colors.py +15 -13
- exonware/xwsystem/console/cli/console.py +98 -0
- exonware/xwsystem/{cli → console/cli}/contracts.py +51 -69
- exonware/xwsystem/console/cli/defs.py +87 -0
- exonware/xwsystem/console/cli/encoding.py +69 -0
- exonware/xwsystem/{cli → console/cli}/errors.py +8 -3
- exonware/xwsystem/console/cli/event_logger.py +166 -0
- exonware/xwsystem/{cli → console/cli}/progress.py +25 -21
- exonware/xwsystem/{cli → console/cli}/prompts.py +3 -2
- exonware/xwsystem/{cli → console/cli}/tables.py +27 -24
- exonware/xwsystem/console/contracts.py +113 -0
- exonware/xwsystem/console/defs.py +154 -0
- exonware/xwsystem/console/errors.py +34 -0
- exonware/xwsystem/console/event_logger.py +385 -0
- exonware/xwsystem/console/writer.py +132 -0
- exonware/xwsystem/contracts.py +28 -0
- exonware/xwsystem/data_structures/__init__.py +23 -0
- exonware/xwsystem/data_structures/trie.py +34 -0
- exonware/xwsystem/data_structures/union_find.py +144 -0
- exonware/xwsystem/defs.py +17 -0
- exonware/xwsystem/errors.py +23 -0
- exonware/xwsystem/facade.py +62 -0
- exonware/xwsystem/http_client/__init__.py +22 -1
- exonware/xwsystem/http_client/advanced_client.py +8 -5
- exonware/xwsystem/http_client/base.py +3 -2
- exonware/xwsystem/http_client/client.py +7 -4
- exonware/xwsystem/http_client/contracts.py +42 -56
- exonware/xwsystem/http_client/defs.py +2 -1
- exonware/xwsystem/http_client/errors.py +2 -1
- exonware/xwsystem/http_client/facade.py +156 -0
- exonware/xwsystem/io/__init__.py +22 -3
- exonware/xwsystem/io/archive/__init__.py +8 -2
- exonware/xwsystem/io/archive/archive.py +1 -1
- exonware/xwsystem/io/archive/archive_files.py +4 -7
- exonware/xwsystem/io/archive/archivers.py +120 -10
- exonware/xwsystem/io/archive/base.py +4 -5
- exonware/xwsystem/io/archive/codec_integration.py +1 -2
- exonware/xwsystem/io/archive/compression.py +1 -2
- exonware/xwsystem/io/archive/facade.py +263 -0
- exonware/xwsystem/io/archive/formats/__init__.py +2 -3
- exonware/xwsystem/io/archive/formats/brotli_format.py +20 -7
- exonware/xwsystem/io/archive/formats/lz4_format.py +20 -7
- exonware/xwsystem/io/archive/formats/rar.py +11 -5
- exonware/xwsystem/io/archive/formats/sevenzip.py +12 -6
- exonware/xwsystem/io/archive/formats/squashfs_format.py +1 -2
- exonware/xwsystem/io/archive/formats/tar.py +52 -7
- exonware/xwsystem/io/archive/formats/wim_format.py +11 -5
- exonware/xwsystem/io/archive/formats/zip.py +1 -2
- exonware/xwsystem/io/archive/formats/zpaq_format.py +1 -2
- exonware/xwsystem/io/archive/formats/zstandard.py +20 -7
- exonware/xwsystem/io/base.py +119 -115
- exonware/xwsystem/io/codec/__init__.py +4 -2
- exonware/xwsystem/io/codec/base.py +19 -13
- exonware/xwsystem/io/codec/contracts.py +59 -2
- exonware/xwsystem/io/codec/registry.py +67 -21
- exonware/xwsystem/io/common/__init__.py +1 -1
- exonware/xwsystem/io/common/atomic.py +29 -16
- exonware/xwsystem/io/common/base.py +11 -10
- exonware/xwsystem/io/common/lock.py +6 -5
- exonware/xwsystem/io/common/path_manager.py +2 -1
- exonware/xwsystem/io/common/watcher.py +1 -2
- exonware/xwsystem/io/contracts.py +301 -433
- exonware/xwsystem/io/contracts_1.py +1180 -0
- exonware/xwsystem/io/data_operations.py +19 -20
- exonware/xwsystem/io/defs.py +4 -3
- exonware/xwsystem/io/errors.py +3 -2
- exonware/xwsystem/io/facade.py +87 -61
- exonware/xwsystem/io/file/__init__.py +1 -1
- exonware/xwsystem/io/file/base.py +8 -9
- exonware/xwsystem/io/file/conversion.py +2 -3
- exonware/xwsystem/io/file/file.py +61 -18
- exonware/xwsystem/io/file/paged_source.py +8 -8
- exonware/xwsystem/io/file/paging/__init__.py +1 -2
- exonware/xwsystem/io/file/paging/byte_paging.py +4 -5
- exonware/xwsystem/io/file/paging/line_paging.py +2 -3
- exonware/xwsystem/io/file/paging/record_paging.py +2 -3
- exonware/xwsystem/io/file/paging/registry.py +1 -2
- exonware/xwsystem/io/file/source.py +13 -17
- exonware/xwsystem/io/filesystem/__init__.py +1 -1
- exonware/xwsystem/io/filesystem/base.py +1 -2
- exonware/xwsystem/io/filesystem/local.py +3 -4
- exonware/xwsystem/io/folder/__init__.py +1 -1
- exonware/xwsystem/io/folder/base.py +1 -2
- exonware/xwsystem/io/folder/folder.py +16 -7
- exonware/xwsystem/io/indexing/__init__.py +14 -0
- exonware/xwsystem/io/indexing/facade.py +443 -0
- exonware/xwsystem/io/path_parser.py +98 -0
- exonware/xwsystem/io/serialization/__init__.py +21 -3
- exonware/xwsystem/io/serialization/auto_serializer.py +146 -20
- exonware/xwsystem/io/serialization/base.py +84 -34
- exonware/xwsystem/io/serialization/contracts.py +50 -73
- exonware/xwsystem/io/serialization/defs.py +2 -1
- exonware/xwsystem/io/serialization/errors.py +2 -1
- exonware/xwsystem/io/serialization/flyweight.py +154 -7
- exonware/xwsystem/io/serialization/format_detector.py +15 -14
- exonware/xwsystem/io/serialization/formats/__init__.py +8 -5
- exonware/xwsystem/io/serialization/formats/binary/bson.py +15 -6
- exonware/xwsystem/io/serialization/formats/binary/cbor.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/marshal.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/msgpack.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/pickle.py +5 -5
- exonware/xwsystem/io/serialization/formats/binary/plistlib.py +5 -5
- exonware/xwsystem/io/serialization/formats/database/dbm.py +7 -7
- exonware/xwsystem/io/serialization/formats/database/shelve.py +7 -7
- exonware/xwsystem/io/serialization/formats/database/sqlite3.py +7 -7
- exonware/xwsystem/io/serialization/formats/tabular/__init__.py +27 -0
- exonware/xwsystem/io/serialization/formats/tabular/base.py +89 -0
- exonware/xwsystem/io/serialization/formats/tabular/csv.py +319 -0
- exonware/xwsystem/io/serialization/formats/tabular/df.py +249 -0
- exonware/xwsystem/io/serialization/formats/tabular/excel.py +291 -0
- exonware/xwsystem/io/serialization/formats/tabular/googlesheets.py +374 -0
- exonware/xwsystem/io/serialization/formats/text/__init__.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/append_only_log.py +5 -7
- exonware/xwsystem/io/serialization/formats/text/configparser.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/csv.py +7 -5
- exonware/xwsystem/io/serialization/formats/text/formdata.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/json.py +27 -18
- exonware/xwsystem/io/serialization/formats/text/json5.py +8 -4
- exonware/xwsystem/io/serialization/formats/text/jsonlines.py +18 -14
- exonware/xwsystem/io/serialization/formats/text/multipart.py +5 -5
- exonware/xwsystem/io/serialization/formats/text/toml.py +8 -6
- exonware/xwsystem/io/serialization/formats/text/xml.py +25 -20
- exonware/xwsystem/io/serialization/formats/text/yaml.py +8 -6
- exonware/xwsystem/io/serialization/parsers/__init__.py +3 -2
- exonware/xwsystem/io/serialization/parsers/base.py +6 -5
- exonware/xwsystem/io/serialization/parsers/hybrid_parser.py +7 -6
- exonware/xwsystem/io/serialization/parsers/msgspec_parser.py +10 -7
- exonware/xwsystem/io/serialization/parsers/orjson_direct_parser.py +7 -6
- exonware/xwsystem/io/serialization/parsers/orjson_parser.py +11 -8
- exonware/xwsystem/io/serialization/parsers/pysimdjson_parser.py +13 -9
- exonware/xwsystem/io/serialization/parsers/rapidjson_parser.py +10 -7
- exonware/xwsystem/io/serialization/parsers/registry.py +11 -10
- exonware/xwsystem/io/serialization/parsers/standard.py +7 -6
- exonware/xwsystem/io/serialization/parsers/ujson_parser.py +10 -7
- exonware/xwsystem/io/serialization/registry.py +4 -4
- exonware/xwsystem/io/serialization/serializer.py +168 -79
- exonware/xwsystem/io/serialization/universal_options.py +367 -0
- exonware/xwsystem/io/serialization/utils/__init__.py +1 -2
- exonware/xwsystem/io/serialization/utils/path_ops.py +5 -6
- exonware/xwsystem/io/source_reader.py +223 -0
- exonware/xwsystem/io/stream/__init__.py +1 -1
- exonware/xwsystem/io/stream/async_operations.py +61 -14
- exonware/xwsystem/io/stream/base.py +1 -2
- exonware/xwsystem/io/stream/codec_io.py +6 -7
- exonware/xwsystem/ipc/__init__.py +1 -0
- exonware/xwsystem/ipc/async_fabric.py +4 -4
- exonware/xwsystem/ipc/base.py +6 -5
- exonware/xwsystem/ipc/contracts.py +41 -66
- exonware/xwsystem/ipc/defs.py +2 -1
- exonware/xwsystem/ipc/errors.py +2 -1
- exonware/xwsystem/ipc/message_queue.py +5 -2
- exonware/xwsystem/ipc/pipes.py +70 -34
- exonware/xwsystem/ipc/process_manager.py +7 -5
- exonware/xwsystem/ipc/process_pool.py +6 -5
- exonware/xwsystem/ipc/shared_memory.py +64 -11
- exonware/xwsystem/monitoring/__init__.py +7 -0
- exonware/xwsystem/monitoring/base.py +11 -8
- exonware/xwsystem/monitoring/contracts.py +86 -144
- exonware/xwsystem/monitoring/defs.py +2 -1
- exonware/xwsystem/monitoring/error_recovery.py +16 -3
- exonware/xwsystem/monitoring/errors.py +2 -1
- exonware/xwsystem/monitoring/facade.py +183 -0
- exonware/xwsystem/monitoring/memory_monitor.py +1 -0
- exonware/xwsystem/monitoring/metrics.py +1 -0
- exonware/xwsystem/monitoring/performance_manager_generic.py +7 -7
- exonware/xwsystem/monitoring/performance_monitor.py +1 -0
- exonware/xwsystem/monitoring/performance_validator.py +1 -0
- exonware/xwsystem/monitoring/system_monitor.py +6 -5
- exonware/xwsystem/monitoring/tracing.py +18 -16
- exonware/xwsystem/monitoring/tracker.py +2 -1
- exonware/xwsystem/operations/__init__.py +5 -50
- exonware/xwsystem/operations/base.py +3 -44
- exonware/xwsystem/operations/contracts.py +25 -15
- exonware/xwsystem/operations/defs.py +1 -1
- exonware/xwsystem/operations/diff.py +5 -4
- exonware/xwsystem/operations/errors.py +1 -1
- exonware/xwsystem/operations/merge.py +6 -4
- exonware/xwsystem/operations/patch.py +5 -4
- exonware/xwsystem/patterns/__init__.py +1 -0
- exonware/xwsystem/patterns/base.py +2 -1
- exonware/xwsystem/patterns/context_manager.py +2 -1
- exonware/xwsystem/patterns/contracts.py +215 -256
- exonware/xwsystem/patterns/defs.py +2 -1
- exonware/xwsystem/patterns/dynamic_facade.py +1 -0
- exonware/xwsystem/patterns/errors.py +2 -4
- exonware/xwsystem/patterns/handler_factory.py +2 -3
- exonware/xwsystem/patterns/import_registry.py +1 -0
- exonware/xwsystem/patterns/object_pool.py +1 -0
- exonware/xwsystem/patterns/registry.py +4 -43
- exonware/xwsystem/plugins/__init__.py +2 -1
- exonware/xwsystem/plugins/base.py +6 -5
- exonware/xwsystem/plugins/contracts.py +94 -158
- exonware/xwsystem/plugins/defs.py +2 -1
- exonware/xwsystem/plugins/errors.py +2 -1
- exonware/xwsystem/py.typed +3 -0
- exonware/xwsystem/query/__init__.py +36 -0
- exonware/xwsystem/query/contracts.py +56 -0
- exonware/xwsystem/query/errors.py +22 -0
- exonware/xwsystem/query/registry.py +128 -0
- exonware/xwsystem/runtime/__init__.py +2 -1
- exonware/xwsystem/runtime/base.py +4 -3
- exonware/xwsystem/runtime/contracts.py +39 -60
- exonware/xwsystem/runtime/defs.py +2 -1
- exonware/xwsystem/runtime/env.py +11 -9
- exonware/xwsystem/runtime/errors.py +2 -1
- exonware/xwsystem/runtime/reflection.py +3 -2
- exonware/xwsystem/security/__init__.py +68 -11
- exonware/xwsystem/security/audit.py +167 -0
- exonware/xwsystem/security/base.py +121 -24
- exonware/xwsystem/security/contracts.py +91 -146
- exonware/xwsystem/security/crypto.py +17 -16
- exonware/xwsystem/security/defs.py +2 -1
- exonware/xwsystem/security/errors.py +2 -1
- exonware/xwsystem/security/facade.py +321 -0
- exonware/xwsystem/security/file_security.py +330 -0
- exonware/xwsystem/security/hazmat.py +11 -8
- exonware/xwsystem/security/monitor.py +372 -0
- exonware/xwsystem/security/path_validator.py +140 -18
- exonware/xwsystem/security/policy.py +357 -0
- exonware/xwsystem/security/resource_limits.py +1 -0
- exonware/xwsystem/security/validator.py +455 -0
- exonware/xwsystem/shared/__init__.py +14 -1
- exonware/xwsystem/shared/base.py +285 -2
- exonware/xwsystem/shared/contracts.py +415 -126
- exonware/xwsystem/shared/defs.py +2 -1
- exonware/xwsystem/shared/errors.py +2 -2
- exonware/xwsystem/shared/xwobject.py +316 -0
- exonware/xwsystem/structures/__init__.py +1 -0
- exonware/xwsystem/structures/base.py +3 -2
- exonware/xwsystem/structures/circular_detector.py +15 -14
- exonware/xwsystem/structures/contracts.py +53 -76
- exonware/xwsystem/structures/defs.py +2 -1
- exonware/xwsystem/structures/errors.py +2 -1
- exonware/xwsystem/structures/tree_walker.py +2 -1
- exonware/xwsystem/threading/__init__.py +21 -4
- exonware/xwsystem/threading/async_primitives.py +6 -5
- exonware/xwsystem/threading/base.py +3 -2
- exonware/xwsystem/threading/contracts.py +87 -143
- exonware/xwsystem/threading/defs.py +2 -1
- exonware/xwsystem/threading/errors.py +2 -1
- exonware/xwsystem/threading/facade.py +175 -0
- exonware/xwsystem/threading/locks.py +1 -0
- exonware/xwsystem/threading/safe_factory.py +1 -0
- exonware/xwsystem/utils/__init__.py +40 -0
- exonware/xwsystem/utils/base.py +22 -21
- exonware/xwsystem/utils/contracts.py +50 -73
- exonware/xwsystem/utils/dt/__init__.py +19 -3
- exonware/xwsystem/utils/dt/base.py +5 -4
- exonware/xwsystem/utils/dt/contracts.py +22 -29
- exonware/xwsystem/utils/dt/defs.py +2 -1
- exonware/xwsystem/utils/dt/errors.py +2 -5
- exonware/xwsystem/utils/dt/formatting.py +88 -2
- exonware/xwsystem/utils/dt/humanize.py +10 -9
- exonware/xwsystem/utils/dt/parsing.py +56 -5
- exonware/xwsystem/utils/dt/timezone_utils.py +2 -24
- exonware/xwsystem/utils/errors.py +2 -4
- exonware/xwsystem/utils/paths.py +1 -0
- exonware/xwsystem/utils/string.py +49 -0
- exonware/xwsystem/utils/test_runner.py +185 -0
- exonware/xwsystem/utils/utils_contracts.py +2 -1
- exonware/xwsystem/utils/web.py +110 -0
- exonware/xwsystem/validation/__init__.py +25 -1
- exonware/xwsystem/validation/base.py +6 -5
- exonware/xwsystem/validation/contracts.py +29 -41
- exonware/xwsystem/validation/data_validator.py +1 -0
- exonware/xwsystem/validation/declarative.py +11 -8
- exonware/xwsystem/validation/defs.py +2 -1
- exonware/xwsystem/validation/errors.py +2 -1
- exonware/xwsystem/validation/facade.py +198 -0
- exonware/xwsystem/validation/fluent_validator.py +22 -19
- exonware/xwsystem/validation/schema_discovery.py +210 -0
- exonware/xwsystem/validation/type_safety.py +2 -1
- exonware/xwsystem/version.py +2 -2
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.3.dist-info}/METADATA +71 -4
- exonware_xwsystem-0.1.0.3.dist-info/RECORD +337 -0
- exonware/xwsystem/cli/__init__.py +0 -43
- exonware/xwsystem/cli/console.py +0 -113
- exonware/xwsystem/cli/defs.py +0 -134
- exonware/xwsystem/conf.py +0 -44
- exonware/xwsystem/security/auth.py +0 -484
- exonware_xwsystem-0.1.0.1.dist-info/RECORD +0 -284
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.3.dist-info}/WHEEL +0 -0
- {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
#exonware/xwsystem/src/exonware/xwsystem/patterns/contracts.py
|
|
1
2
|
#exonware/xwsystem/patterns/contracts.py
|
|
2
3
|
"""
|
|
3
4
|
Company: eXonware.com
|
|
4
5
|
Author: Eng. Muhammad AlShehri
|
|
5
6
|
Email: connect@exonware.com
|
|
6
|
-
Version: 0.1.0.
|
|
7
|
+
Version: 0.1.0.3
|
|
7
8
|
Generation Date: September 04, 2025
|
|
8
9
|
|
|
9
10
|
Pattern contracts and interfaces for XWSystem design patterns.
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
|
-
from
|
|
13
|
-
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Any, Optional, Callable, Protocol, runtime_checkable
|
|
14
16
|
# Root cause: Migrating to Python 3.12 built-in generic syntax for consistency
|
|
15
17
|
# Priority #3: Maintainability - Modern type annotations improve code clarity
|
|
16
18
|
|
|
@@ -49,658 +51,615 @@ from .defs import (
|
|
|
49
51
|
# CORE INTERFACES
|
|
50
52
|
# ============================================================================
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
@runtime_checkable
|
|
55
|
+
class IHandler[T](Protocol):
|
|
53
56
|
"""Interface for handlers in the chain of responsibility pattern."""
|
|
54
57
|
|
|
55
|
-
@abstractmethod
|
|
56
58
|
def handle(self, request: T) -> T:
|
|
57
59
|
"""Handle the request."""
|
|
58
|
-
|
|
60
|
+
...
|
|
59
61
|
|
|
60
|
-
@abstractmethod
|
|
61
62
|
def can_handle(self, request: T) -> bool:
|
|
62
63
|
"""Check if this handler can handle the request."""
|
|
63
|
-
|
|
64
|
+
...
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
def set_next(self, handler: 'IHandler[T]') -> 'IHandler[T]':
|
|
66
|
+
def set_next(self, handler: IHandler[T]) -> IHandler[T]:
|
|
67
67
|
"""Set the next handler in the chain."""
|
|
68
|
-
|
|
68
|
+
...
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
@runtime_checkable
|
|
72
|
+
class IHandlerFactory[T](Protocol):
|
|
72
73
|
"""Interface for handler factories."""
|
|
73
74
|
|
|
74
|
-
@abstractmethod
|
|
75
75
|
def create_handler(self, handler_type: str, **kwargs) -> T:
|
|
76
76
|
"""Create a handler of the specified type."""
|
|
77
|
-
|
|
77
|
+
...
|
|
78
78
|
|
|
79
|
-
@abstractmethod
|
|
80
79
|
def register_handler(self, handler_type: str, handler_class: type[T]) -> None:
|
|
81
80
|
"""Register a handler class."""
|
|
82
|
-
|
|
81
|
+
...
|
|
83
82
|
|
|
84
|
-
@abstractmethod
|
|
85
83
|
def unregister_handler(self, handler_type: str) -> None:
|
|
86
84
|
"""Unregister a handler class."""
|
|
87
|
-
|
|
85
|
+
...
|
|
88
86
|
|
|
89
|
-
@abstractmethod
|
|
90
87
|
def list_handlers(self) -> list[str]:
|
|
91
88
|
"""List all registered handler types."""
|
|
92
|
-
|
|
89
|
+
...
|
|
93
90
|
|
|
94
|
-
@abstractmethod
|
|
95
91
|
def has_handler(self, handler_type: str) -> bool:
|
|
96
92
|
"""Check if a handler type is registered."""
|
|
97
|
-
|
|
93
|
+
...
|
|
98
94
|
|
|
99
95
|
|
|
100
|
-
|
|
96
|
+
@runtime_checkable
|
|
97
|
+
class IContextManager(Protocol):
|
|
101
98
|
"""Interface for context managers."""
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
def __enter__(self) -> 'IContextManager':
|
|
100
|
+
def __enter__(self) -> IContextManager:
|
|
105
101
|
"""Enter the context."""
|
|
106
|
-
|
|
102
|
+
...
|
|
107
103
|
|
|
108
|
-
@abstractmethod
|
|
109
104
|
def __exit__(self, exc_type: Optional[type[BaseException]],
|
|
110
105
|
exc_val: Optional[BaseException],
|
|
111
106
|
exc_tb: Optional[Any]) -> bool:
|
|
112
107
|
"""Exit the context."""
|
|
113
|
-
|
|
108
|
+
...
|
|
114
109
|
|
|
115
|
-
@abstractmethod
|
|
116
110
|
def is_active(self) -> bool:
|
|
117
111
|
"""Check if context is active."""
|
|
118
|
-
|
|
112
|
+
...
|
|
119
113
|
|
|
120
|
-
@abstractmethod
|
|
121
114
|
def get_context_data(self) -> dict[str, Any]:
|
|
122
115
|
"""Get context data."""
|
|
123
|
-
|
|
116
|
+
...
|
|
124
117
|
|
|
125
118
|
|
|
126
|
-
|
|
119
|
+
@runtime_checkable
|
|
120
|
+
class IObjectPool[T](Protocol):
|
|
127
121
|
"""Interface for object pools."""
|
|
128
122
|
|
|
129
|
-
@abstractmethod
|
|
130
123
|
def get(self, obj_type: type[T], *args, **kwargs) -> T:
|
|
131
124
|
"""Get an object from the pool."""
|
|
132
|
-
|
|
125
|
+
...
|
|
133
126
|
|
|
134
|
-
@abstractmethod
|
|
135
127
|
def release(self, obj: T) -> None:
|
|
136
128
|
"""Release an object back to the pool."""
|
|
137
|
-
|
|
129
|
+
...
|
|
138
130
|
|
|
139
|
-
@abstractmethod
|
|
140
131
|
def clear(self, obj_type: Optional[type[T]] = None) -> None:
|
|
141
132
|
"""Clear objects from the pool."""
|
|
142
|
-
|
|
133
|
+
...
|
|
143
134
|
|
|
144
|
-
@abstractmethod
|
|
145
135
|
def get_stats(self) -> dict[str, Any]:
|
|
146
136
|
"""Get pool statistics."""
|
|
147
|
-
|
|
137
|
+
...
|
|
148
138
|
|
|
149
|
-
@abstractmethod
|
|
150
139
|
def is_empty(self, obj_type: type[T]) -> bool:
|
|
151
140
|
"""Check if pool is empty for a type."""
|
|
152
|
-
|
|
141
|
+
...
|
|
153
142
|
|
|
154
143
|
|
|
155
|
-
|
|
144
|
+
@runtime_checkable
|
|
145
|
+
class IRegistry[K, V](Protocol):
|
|
156
146
|
"""Interface for registries."""
|
|
157
147
|
|
|
158
|
-
@abstractmethod
|
|
159
148
|
def register(self, key: K, value: V) -> None:
|
|
160
149
|
"""Register a value with a key."""
|
|
161
|
-
|
|
150
|
+
...
|
|
162
151
|
|
|
163
|
-
@abstractmethod
|
|
164
152
|
def unregister(self, key: K) -> V:
|
|
165
153
|
"""Unregister a value by key."""
|
|
166
|
-
|
|
154
|
+
...
|
|
167
155
|
|
|
168
|
-
@abstractmethod
|
|
169
156
|
def get(self, key: K) -> Optional[V]:
|
|
170
157
|
"""Get a value by key."""
|
|
171
|
-
|
|
158
|
+
...
|
|
172
159
|
|
|
173
|
-
@abstractmethod
|
|
174
160
|
def has(self, key: K) -> bool:
|
|
175
161
|
"""Check if key exists."""
|
|
176
|
-
|
|
162
|
+
...
|
|
177
163
|
|
|
178
|
-
@abstractmethod
|
|
179
164
|
def list_keys(self) -> list[K]:
|
|
180
165
|
"""List all keys."""
|
|
181
|
-
|
|
166
|
+
...
|
|
182
167
|
|
|
183
|
-
@abstractmethod
|
|
184
168
|
def list_values(self) -> list[V]:
|
|
185
169
|
"""List all values."""
|
|
186
|
-
|
|
170
|
+
...
|
|
187
171
|
|
|
188
|
-
@abstractmethod
|
|
189
172
|
def clear(self) -> None:
|
|
190
173
|
"""Clear all entries."""
|
|
191
|
-
|
|
174
|
+
...
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@runtime_checkable
|
|
178
|
+
class IGenericRegistry[T](Protocol):
|
|
179
|
+
"""
|
|
180
|
+
Interface for generic registry implementations with metadata support.
|
|
181
|
+
|
|
182
|
+
Root cause: Adding generic type parameter for better type safety.
|
|
183
|
+
Priority #3: Maintainability - Generic types improve code clarity and type checking.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
def register(self, name: str, item: T, metadata: Optional[dict[str, Any]] = None) -> bool:
|
|
187
|
+
"""Register an item with optional metadata."""
|
|
188
|
+
...
|
|
189
|
+
|
|
190
|
+
def unregister(self, name: str) -> bool:
|
|
191
|
+
"""Unregister an item."""
|
|
192
|
+
...
|
|
193
|
+
|
|
194
|
+
def get(self, name: str) -> Optional[T]:
|
|
195
|
+
"""Get an item by name."""
|
|
196
|
+
...
|
|
197
|
+
|
|
198
|
+
def list_names(self) -> list[str]:
|
|
199
|
+
"""List all registered names."""
|
|
200
|
+
...
|
|
201
|
+
|
|
202
|
+
def exists(self, name: str) -> bool:
|
|
203
|
+
"""Check if an item exists."""
|
|
204
|
+
...
|
|
205
|
+
|
|
206
|
+
def clear(self) -> bool:
|
|
207
|
+
"""Clear all registrations."""
|
|
208
|
+
...
|
|
192
209
|
|
|
193
210
|
|
|
194
|
-
|
|
211
|
+
@runtime_checkable
|
|
212
|
+
class IStrategy(Protocol):
|
|
195
213
|
"""Interface for strategies."""
|
|
196
214
|
|
|
197
|
-
@abstractmethod
|
|
198
215
|
def execute(self, context: Any) -> Any:
|
|
199
216
|
"""Execute the strategy."""
|
|
200
|
-
|
|
217
|
+
...
|
|
201
218
|
|
|
202
|
-
@abstractmethod
|
|
203
219
|
def can_handle(self, context: Any) -> bool:
|
|
204
220
|
"""Check if strategy can handle context."""
|
|
205
|
-
|
|
221
|
+
...
|
|
206
222
|
|
|
207
|
-
@abstractmethod
|
|
208
223
|
def get_name(self) -> str:
|
|
209
224
|
"""Get strategy name."""
|
|
210
|
-
|
|
225
|
+
...
|
|
211
226
|
|
|
212
227
|
|
|
213
|
-
|
|
228
|
+
@runtime_checkable
|
|
229
|
+
class IObserver(Protocol):
|
|
214
230
|
"""Interface for observers."""
|
|
215
231
|
|
|
216
|
-
|
|
217
|
-
def update(self, subject: 'ISubject', event: Any) -> None:
|
|
232
|
+
def update(self, subject: ISubject, event: Any) -> None:
|
|
218
233
|
"""Update the observer."""
|
|
219
|
-
|
|
234
|
+
...
|
|
220
235
|
|
|
221
|
-
@abstractmethod
|
|
222
236
|
def get_id(self) -> str:
|
|
223
237
|
"""Get observer ID."""
|
|
224
|
-
|
|
238
|
+
...
|
|
225
239
|
|
|
226
240
|
|
|
227
|
-
|
|
241
|
+
@runtime_checkable
|
|
242
|
+
class ISubject(Protocol):
|
|
228
243
|
"""Interface for subjects."""
|
|
229
244
|
|
|
230
|
-
@abstractmethod
|
|
231
245
|
def attach(self, observer: IObserver) -> None:
|
|
232
246
|
"""Attach an observer."""
|
|
233
|
-
|
|
247
|
+
...
|
|
234
248
|
|
|
235
|
-
@abstractmethod
|
|
236
249
|
def detach(self, observer: IObserver) -> None:
|
|
237
250
|
"""Detach an observer."""
|
|
238
|
-
|
|
251
|
+
...
|
|
239
252
|
|
|
240
|
-
@abstractmethod
|
|
241
253
|
def notify(self, event: Any) -> None:
|
|
242
254
|
"""Notify all observers."""
|
|
243
|
-
|
|
255
|
+
...
|
|
244
256
|
|
|
245
257
|
|
|
246
|
-
|
|
258
|
+
@runtime_checkable
|
|
259
|
+
class ICommand(Protocol):
|
|
247
260
|
"""Interface for commands."""
|
|
248
261
|
|
|
249
|
-
@abstractmethod
|
|
250
262
|
def execute(self) -> Any:
|
|
251
263
|
"""Execute the command."""
|
|
252
|
-
|
|
264
|
+
...
|
|
253
265
|
|
|
254
|
-
@abstractmethod
|
|
255
266
|
def undo(self) -> Any:
|
|
256
267
|
"""Undo the command."""
|
|
257
|
-
|
|
268
|
+
...
|
|
258
269
|
|
|
259
|
-
@abstractmethod
|
|
260
270
|
def can_undo(self) -> bool:
|
|
261
271
|
"""Check if command can be undone."""
|
|
262
|
-
|
|
272
|
+
...
|
|
263
273
|
|
|
264
|
-
@abstractmethod
|
|
265
274
|
def get_description(self) -> str:
|
|
266
275
|
"""Get command description."""
|
|
267
|
-
|
|
276
|
+
...
|
|
268
277
|
|
|
269
278
|
|
|
270
|
-
|
|
279
|
+
@runtime_checkable
|
|
280
|
+
class IState(Protocol):
|
|
271
281
|
"""Interface for states."""
|
|
272
282
|
|
|
273
|
-
@abstractmethod
|
|
274
283
|
def enter(self, context: Any) -> None:
|
|
275
284
|
"""Enter the state."""
|
|
276
|
-
|
|
285
|
+
...
|
|
277
286
|
|
|
278
|
-
@abstractmethod
|
|
279
287
|
def exit(self, context: Any) -> None:
|
|
280
288
|
"""Exit the state."""
|
|
281
|
-
|
|
289
|
+
...
|
|
282
290
|
|
|
283
|
-
@abstractmethod
|
|
284
291
|
def handle(self, context: Any, event: Any) -> None:
|
|
285
292
|
"""Handle an event in this state."""
|
|
286
|
-
|
|
293
|
+
...
|
|
287
294
|
|
|
288
|
-
@abstractmethod
|
|
289
295
|
def get_name(self) -> str:
|
|
290
296
|
"""Get state name."""
|
|
291
|
-
|
|
297
|
+
...
|
|
292
298
|
|
|
293
299
|
|
|
294
|
-
|
|
300
|
+
@runtime_checkable
|
|
301
|
+
class IBuilder[T](Protocol):
|
|
295
302
|
"""Interface for builders."""
|
|
296
303
|
|
|
297
|
-
@abstractmethod
|
|
298
304
|
def build(self) -> T:
|
|
299
305
|
"""Build the object."""
|
|
300
|
-
|
|
306
|
+
...
|
|
301
307
|
|
|
302
|
-
|
|
303
|
-
def reset(self) -> 'IBuilder[T]':
|
|
308
|
+
def reset(self) -> IBuilder[T]:
|
|
304
309
|
"""Reset the builder."""
|
|
305
|
-
|
|
310
|
+
...
|
|
306
311
|
|
|
307
|
-
@abstractmethod
|
|
308
312
|
def is_valid(self) -> bool:
|
|
309
313
|
"""Check if builder is in valid state."""
|
|
310
|
-
|
|
314
|
+
...
|
|
311
315
|
|
|
312
316
|
|
|
313
|
-
|
|
317
|
+
@runtime_checkable
|
|
318
|
+
class IPrototype[T](Protocol):
|
|
314
319
|
"""Interface for prototypes."""
|
|
315
320
|
|
|
316
|
-
@abstractmethod
|
|
317
321
|
def clone(self) -> T:
|
|
318
322
|
"""Clone the object."""
|
|
319
|
-
|
|
323
|
+
...
|
|
320
324
|
|
|
321
|
-
@abstractmethod
|
|
322
325
|
def deep_clone(self) -> T:
|
|
323
326
|
"""Create a deep clone."""
|
|
324
|
-
|
|
327
|
+
...
|
|
325
328
|
|
|
326
|
-
@abstractmethod
|
|
327
329
|
def shallow_clone(self) -> T:
|
|
328
330
|
"""Create a shallow clone."""
|
|
329
|
-
|
|
331
|
+
...
|
|
330
332
|
|
|
331
333
|
|
|
332
|
-
|
|
334
|
+
@runtime_checkable
|
|
335
|
+
class IAdapter(Protocol):
|
|
333
336
|
"""Interface for adapters."""
|
|
334
337
|
|
|
335
|
-
@abstractmethod
|
|
336
338
|
def adapt(self, source: Any) -> Any:
|
|
337
339
|
"""Adapt source to target."""
|
|
338
|
-
|
|
340
|
+
...
|
|
339
341
|
|
|
340
|
-
@abstractmethod
|
|
341
342
|
def can_adapt(self, source: Any) -> bool:
|
|
342
343
|
"""Check if source can be adapted."""
|
|
343
|
-
|
|
344
|
+
...
|
|
344
345
|
|
|
345
|
-
@abstractmethod
|
|
346
346
|
def get_source_type(self) -> type:
|
|
347
347
|
"""Get source type."""
|
|
348
|
-
|
|
348
|
+
...
|
|
349
349
|
|
|
350
|
-
@abstractmethod
|
|
351
350
|
def get_target_type(self) -> type:
|
|
352
351
|
"""Get target type."""
|
|
353
|
-
|
|
352
|
+
...
|
|
354
353
|
|
|
355
354
|
|
|
356
|
-
|
|
355
|
+
@runtime_checkable
|
|
356
|
+
class IDecorator[T](Protocol):
|
|
357
357
|
"""Interface for decorators."""
|
|
358
358
|
|
|
359
|
-
@abstractmethod
|
|
360
359
|
def decorate(self, target: T) -> T:
|
|
361
360
|
"""Decorate the target."""
|
|
362
|
-
|
|
361
|
+
...
|
|
363
362
|
|
|
364
|
-
@abstractmethod
|
|
365
363
|
def undecorate(self, target: T) -> T:
|
|
366
364
|
"""Remove decoration from target."""
|
|
367
|
-
|
|
365
|
+
...
|
|
368
366
|
|
|
369
|
-
@abstractmethod
|
|
370
367
|
def is_decorated(self, target: T) -> bool:
|
|
371
368
|
"""Check if target is decorated."""
|
|
372
|
-
|
|
369
|
+
...
|
|
373
370
|
|
|
374
371
|
|
|
375
|
-
|
|
372
|
+
@runtime_checkable
|
|
373
|
+
class IProxy[T](Protocol):
|
|
376
374
|
"""Interface for proxies."""
|
|
377
375
|
|
|
378
|
-
@abstractmethod
|
|
379
376
|
def get_real_object(self) -> T:
|
|
380
377
|
"""Get the real object."""
|
|
381
|
-
|
|
378
|
+
...
|
|
382
379
|
|
|
383
|
-
@abstractmethod
|
|
384
380
|
def is_accessible(self) -> bool:
|
|
385
381
|
"""Check if real object is accessible."""
|
|
386
|
-
|
|
382
|
+
...
|
|
387
383
|
|
|
388
|
-
@abstractmethod
|
|
389
384
|
def get_proxy_type(self) -> str:
|
|
390
385
|
"""Get proxy type."""
|
|
391
|
-
|
|
386
|
+
...
|
|
392
387
|
|
|
393
388
|
|
|
394
|
-
|
|
389
|
+
@runtime_checkable
|
|
390
|
+
class IFacade(Protocol):
|
|
395
391
|
"""Interface for facades."""
|
|
396
392
|
|
|
397
|
-
@abstractmethod
|
|
398
393
|
def execute(self, operation: str, *args, **kwargs) -> Any:
|
|
399
394
|
"""Execute an operation through the facade."""
|
|
400
|
-
|
|
395
|
+
...
|
|
401
396
|
|
|
402
|
-
@abstractmethod
|
|
403
397
|
def get_available_operations(self) -> list[str]:
|
|
404
398
|
"""Get list of available operations."""
|
|
405
|
-
|
|
399
|
+
...
|
|
406
400
|
|
|
407
|
-
@abstractmethod
|
|
408
401
|
def is_operation_supported(self, operation: str) -> bool:
|
|
409
402
|
"""Check if operation is supported."""
|
|
410
|
-
|
|
403
|
+
...
|
|
411
404
|
|
|
412
405
|
|
|
413
|
-
|
|
406
|
+
@runtime_checkable
|
|
407
|
+
class IDynamicFacade(Protocol):
|
|
414
408
|
"""Interface for dynamic facades."""
|
|
415
409
|
|
|
416
|
-
@abstractmethod
|
|
417
410
|
def get_available_formats(self) -> list[str]:
|
|
418
411
|
"""Get list of available formats."""
|
|
419
|
-
|
|
412
|
+
...
|
|
420
413
|
|
|
421
|
-
@abstractmethod
|
|
422
414
|
def has_format(self, format_name: str) -> bool:
|
|
423
415
|
"""Check if format is available."""
|
|
424
|
-
|
|
416
|
+
...
|
|
425
417
|
|
|
426
|
-
@abstractmethod
|
|
427
418
|
def load(self, source: Any, format_name: str, **kwargs) -> Any:
|
|
428
419
|
"""Load data using specified format."""
|
|
429
|
-
|
|
420
|
+
...
|
|
430
421
|
|
|
431
|
-
@abstractmethod
|
|
432
422
|
def save(self, data: Any, target: Any, format_name: str, **kwargs) -> None:
|
|
433
423
|
"""Save data using specified format."""
|
|
434
|
-
|
|
424
|
+
...
|
|
435
425
|
|
|
436
426
|
|
|
437
|
-
|
|
427
|
+
@runtime_checkable
|
|
428
|
+
class IChainHandler(Protocol):
|
|
438
429
|
"""Interface for chain handlers."""
|
|
439
430
|
|
|
440
|
-
@abstractmethod
|
|
441
431
|
def handle(self, request: Any) -> Any:
|
|
442
432
|
"""Handle the request."""
|
|
443
|
-
|
|
433
|
+
...
|
|
444
434
|
|
|
445
|
-
|
|
446
|
-
def set_next(self, handler: 'IChainHandler') -> 'IChainHandler':
|
|
435
|
+
def set_next(self, handler: IChainHandler) -> IChainHandler:
|
|
447
436
|
"""Set the next handler."""
|
|
448
|
-
|
|
437
|
+
...
|
|
449
438
|
|
|
450
|
-
@abstractmethod
|
|
451
439
|
def can_handle(self, request: Any) -> bool:
|
|
452
440
|
"""Check if can handle request."""
|
|
453
|
-
|
|
441
|
+
...
|
|
454
442
|
|
|
455
443
|
|
|
456
|
-
|
|
444
|
+
@runtime_checkable
|
|
445
|
+
class IMediator(Protocol):
|
|
457
446
|
"""Interface for mediators."""
|
|
458
447
|
|
|
459
|
-
@abstractmethod
|
|
460
448
|
def register_colleague(self, colleague_id: str, colleague: Any) -> None:
|
|
461
449
|
"""Register a colleague."""
|
|
462
|
-
|
|
450
|
+
...
|
|
463
451
|
|
|
464
|
-
@abstractmethod
|
|
465
452
|
def unregister_colleague(self, colleague_id: str) -> None:
|
|
466
453
|
"""Unregister a colleague."""
|
|
467
|
-
|
|
454
|
+
...
|
|
468
455
|
|
|
469
|
-
@abstractmethod
|
|
470
456
|
def send_message(self, sender_id: str, receiver_id: str, message: Any) -> None:
|
|
471
457
|
"""Send a message between colleagues."""
|
|
472
|
-
|
|
458
|
+
...
|
|
473
459
|
|
|
474
|
-
@abstractmethod
|
|
475
460
|
def broadcast_message(self, sender_id: str, message: Any) -> None:
|
|
476
461
|
"""Broadcast a message to all colleagues."""
|
|
477
|
-
|
|
462
|
+
...
|
|
478
463
|
|
|
479
464
|
|
|
480
|
-
|
|
465
|
+
@runtime_checkable
|
|
466
|
+
class IMemento(Protocol):
|
|
481
467
|
"""Interface for mementos."""
|
|
482
468
|
|
|
483
|
-
@abstractmethod
|
|
484
469
|
def get_state(self) -> Any:
|
|
485
470
|
"""Get the saved state."""
|
|
486
|
-
|
|
471
|
+
...
|
|
487
472
|
|
|
488
|
-
@abstractmethod
|
|
489
473
|
def get_timestamp(self) -> float:
|
|
490
474
|
"""Get creation timestamp."""
|
|
491
|
-
|
|
475
|
+
...
|
|
492
476
|
|
|
493
|
-
@abstractmethod
|
|
494
477
|
def get_description(self) -> str:
|
|
495
478
|
"""Get memento description."""
|
|
496
|
-
|
|
479
|
+
...
|
|
497
480
|
|
|
498
481
|
|
|
499
|
-
|
|
482
|
+
@runtime_checkable
|
|
483
|
+
class IOriginator(Protocol):
|
|
500
484
|
"""Interface for originators."""
|
|
501
485
|
|
|
502
|
-
@abstractmethod
|
|
503
486
|
def create_memento(self) -> IMemento:
|
|
504
487
|
"""Create a memento."""
|
|
505
|
-
|
|
488
|
+
...
|
|
506
489
|
|
|
507
|
-
@abstractmethod
|
|
508
490
|
def restore_from_memento(self, memento: IMemento) -> None:
|
|
509
491
|
"""Restore from memento."""
|
|
510
|
-
|
|
492
|
+
...
|
|
511
493
|
|
|
512
494
|
|
|
513
|
-
|
|
495
|
+
@runtime_checkable
|
|
496
|
+
class IVisitor(Protocol):
|
|
514
497
|
"""Interface for visitors."""
|
|
515
498
|
|
|
516
|
-
@abstractmethod
|
|
517
499
|
def visit(self, element: Any) -> Any:
|
|
518
500
|
"""Visit an element."""
|
|
519
|
-
|
|
501
|
+
...
|
|
520
502
|
|
|
521
|
-
@abstractmethod
|
|
522
503
|
def can_visit(self, element: Any) -> bool:
|
|
523
504
|
"""Check if can visit element."""
|
|
524
|
-
|
|
505
|
+
...
|
|
525
506
|
|
|
526
507
|
|
|
527
|
-
|
|
508
|
+
@runtime_checkable
|
|
509
|
+
class IElement(Protocol):
|
|
528
510
|
"""Interface for elements that accept visitors."""
|
|
529
511
|
|
|
530
|
-
@abstractmethod
|
|
531
512
|
def accept(self, visitor: IVisitor) -> Any:
|
|
532
513
|
"""Accept a visitor."""
|
|
533
|
-
|
|
514
|
+
...
|
|
534
515
|
|
|
535
516
|
|
|
536
|
-
|
|
517
|
+
@runtime_checkable
|
|
518
|
+
class IIterator[T](Protocol):
|
|
537
519
|
"""Interface for iterators."""
|
|
538
520
|
|
|
539
|
-
@abstractmethod
|
|
540
521
|
def __next__(self) -> T:
|
|
541
522
|
"""Get next item."""
|
|
542
|
-
|
|
523
|
+
...
|
|
543
524
|
|
|
544
|
-
|
|
545
|
-
def __iter__(self) -> 'IIterator[T]':
|
|
525
|
+
def __iter__(self) -> IIterator[T]:
|
|
546
526
|
"""Get iterator."""
|
|
547
|
-
|
|
527
|
+
...
|
|
548
528
|
|
|
549
|
-
@abstractmethod
|
|
550
529
|
def has_next(self) -> bool:
|
|
551
530
|
"""Check if has next item."""
|
|
552
|
-
|
|
531
|
+
...
|
|
553
532
|
|
|
554
|
-
@abstractmethod
|
|
555
533
|
def reset(self) -> None:
|
|
556
534
|
"""Reset iterator."""
|
|
557
|
-
|
|
535
|
+
...
|
|
558
536
|
|
|
559
537
|
|
|
560
|
-
|
|
538
|
+
@runtime_checkable
|
|
539
|
+
class IConcurrencyControl(Protocol):
|
|
561
540
|
"""Interface for concurrency control."""
|
|
562
541
|
|
|
563
|
-
@abstractmethod
|
|
564
542
|
def acquire(self) -> None:
|
|
565
543
|
"""Acquire the lock."""
|
|
566
|
-
|
|
544
|
+
...
|
|
567
545
|
|
|
568
|
-
@abstractmethod
|
|
569
546
|
def release(self) -> None:
|
|
570
547
|
"""Release the lock."""
|
|
571
|
-
|
|
548
|
+
...
|
|
572
549
|
|
|
573
|
-
@abstractmethod
|
|
574
550
|
def is_locked(self) -> bool:
|
|
575
551
|
"""Check if locked."""
|
|
576
|
-
|
|
552
|
+
...
|
|
577
553
|
|
|
578
|
-
@abstractmethod
|
|
579
554
|
def try_acquire(self, timeout: Optional[float] = None) -> bool:
|
|
580
555
|
"""Try to acquire with timeout."""
|
|
581
|
-
|
|
556
|
+
...
|
|
582
557
|
|
|
583
558
|
|
|
584
|
-
|
|
559
|
+
@runtime_checkable
|
|
560
|
+
class IArchitecturalPattern(Protocol):
|
|
585
561
|
"""Interface for architectural patterns."""
|
|
586
562
|
|
|
587
|
-
@abstractmethod
|
|
588
563
|
def initialize(self) -> None:
|
|
589
564
|
"""Initialize the pattern."""
|
|
590
|
-
|
|
565
|
+
...
|
|
591
566
|
|
|
592
|
-
@abstractmethod
|
|
593
567
|
def shutdown(self) -> None:
|
|
594
568
|
"""Shutdown the pattern."""
|
|
595
|
-
|
|
569
|
+
...
|
|
596
570
|
|
|
597
|
-
@abstractmethod
|
|
598
571
|
def is_initialized(self) -> bool:
|
|
599
572
|
"""Check if initialized."""
|
|
600
|
-
|
|
573
|
+
...
|
|
601
574
|
|
|
602
|
-
@abstractmethod
|
|
603
575
|
def get_components(self) -> list[str]:
|
|
604
576
|
"""Get list of components."""
|
|
605
|
-
|
|
577
|
+
...
|
|
606
578
|
|
|
607
579
|
|
|
608
|
-
|
|
580
|
+
@runtime_checkable
|
|
581
|
+
class ISpecification(Protocol):
|
|
609
582
|
"""Interface for specifications."""
|
|
610
583
|
|
|
611
|
-
@abstractmethod
|
|
612
584
|
def is_satisfied_by(self, candidate: Any) -> bool:
|
|
613
585
|
"""Check if candidate satisfies specification."""
|
|
614
|
-
|
|
586
|
+
...
|
|
615
587
|
|
|
616
|
-
|
|
617
|
-
def and_specification(self, other: 'ISpecification') -> 'ISpecification':
|
|
588
|
+
def and_specification(self, other: ISpecification) -> ISpecification:
|
|
618
589
|
"""Create AND specification."""
|
|
619
|
-
|
|
590
|
+
...
|
|
620
591
|
|
|
621
|
-
|
|
622
|
-
def or_specification(self, other: 'ISpecification') -> 'ISpecification':
|
|
592
|
+
def or_specification(self, other: ISpecification) -> ISpecification:
|
|
623
593
|
"""Create OR specification."""
|
|
624
|
-
|
|
594
|
+
...
|
|
625
595
|
|
|
626
|
-
|
|
627
|
-
def not_specification(self) -> 'ISpecification':
|
|
596
|
+
def not_specification(self) -> ISpecification:
|
|
628
597
|
"""Create NOT specification."""
|
|
629
|
-
|
|
598
|
+
...
|
|
630
599
|
|
|
631
600
|
|
|
632
|
-
|
|
601
|
+
@runtime_checkable
|
|
602
|
+
class IValueObject(Protocol):
|
|
633
603
|
"""Interface for value objects."""
|
|
634
604
|
|
|
635
|
-
@abstractmethod
|
|
636
605
|
def equals(self, other: Any) -> bool:
|
|
637
606
|
"""Check if equal to other."""
|
|
638
|
-
|
|
607
|
+
...
|
|
639
608
|
|
|
640
|
-
@abstractmethod
|
|
641
609
|
def get_hash(self) -> int:
|
|
642
610
|
"""Get hash code."""
|
|
643
|
-
|
|
611
|
+
...
|
|
644
612
|
|
|
645
|
-
@abstractmethod
|
|
646
613
|
def to_string(self) -> str:
|
|
647
614
|
"""Convert to string."""
|
|
648
|
-
|
|
615
|
+
...
|
|
649
616
|
|
|
650
617
|
|
|
651
|
-
|
|
618
|
+
@runtime_checkable
|
|
619
|
+
class IAggregate(Protocol):
|
|
652
620
|
"""Interface for aggregates in domain-driven design."""
|
|
653
621
|
|
|
654
|
-
@abstractmethod
|
|
655
622
|
def get_id(self) -> str:
|
|
656
623
|
"""Get the aggregate ID."""
|
|
657
|
-
|
|
624
|
+
...
|
|
658
625
|
|
|
659
|
-
@abstractmethod
|
|
660
626
|
def get_version(self) -> int:
|
|
661
627
|
"""Get the aggregate version."""
|
|
662
|
-
|
|
628
|
+
...
|
|
663
629
|
|
|
664
|
-
@abstractmethod
|
|
665
630
|
def get_uncommitted_events(self) -> list[Any]:
|
|
666
631
|
"""Get uncommitted events."""
|
|
667
|
-
|
|
632
|
+
...
|
|
668
633
|
|
|
669
|
-
@abstractmethod
|
|
670
634
|
def mark_events_as_committed(self) -> None:
|
|
671
635
|
"""Mark events as committed."""
|
|
672
|
-
|
|
636
|
+
...
|
|
673
637
|
|
|
674
638
|
|
|
675
|
-
|
|
639
|
+
@runtime_checkable
|
|
640
|
+
class IPattern(Protocol):
|
|
676
641
|
"""Interface for design patterns."""
|
|
677
642
|
|
|
678
|
-
@abstractmethod
|
|
679
643
|
def get_pattern_type(self) -> PatternType:
|
|
680
644
|
"""Get pattern type."""
|
|
681
|
-
|
|
645
|
+
...
|
|
682
646
|
|
|
683
|
-
@abstractmethod
|
|
684
647
|
def get_name(self) -> str:
|
|
685
648
|
"""Get pattern name."""
|
|
686
|
-
|
|
649
|
+
...
|
|
687
650
|
|
|
688
|
-
@abstractmethod
|
|
689
651
|
def get_description(self) -> str:
|
|
690
652
|
"""Get pattern description."""
|
|
691
|
-
|
|
653
|
+
...
|
|
692
654
|
|
|
693
|
-
@abstractmethod
|
|
694
655
|
def is_applicable(self, context: Any) -> bool:
|
|
695
656
|
"""Check if pattern is applicable to context."""
|
|
696
|
-
|
|
657
|
+
...
|
|
697
658
|
|
|
698
|
-
@abstractmethod
|
|
699
659
|
def apply(self, context: Any) -> Any:
|
|
700
660
|
"""Apply the pattern to context."""
|
|
701
|
-
|
|
661
|
+
...
|
|
702
662
|
|
|
703
|
-
@abstractmethod
|
|
704
663
|
def validate(self, data: Any) -> bool:
|
|
705
664
|
"""Validate data for pattern application."""
|
|
706
|
-
|
|
665
|
+
...
|