womm-cli 4.0.0__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.
- womm/__init__.py +53 -0
- womm/__main__.py +48 -0
- womm/_version.py +10 -0
- womm/assets/copier/meta/copier.yml +15 -0
- womm/assets/copier/meta/template/README.md.jinja +32 -0
- womm/assets/copier/meta/template/copier.yml.jinja +13 -0
- womm/assets/copier/meta/template/template/.gitkeep +0 -0
- womm/assets/copier/official/javascript/copier.yml +104 -0
- womm/assets/copier/official/javascript/template/.gitignore.jinja +35 -0
- womm/assets/copier/official/javascript/template/.nvmrc.jinja +1 -0
- womm/assets/copier/official/javascript/template/.prettierignore.jinja +10 -0
- womm/assets/copier/official/javascript/template/README.md.jinja +81 -0
- womm/assets/copier/official/javascript/template/biome.json.jinja +54 -0
- womm/assets/copier/official/javascript/template/eslint.config.mjs.jinja +51 -0
- womm/assets/copier/official/javascript/template/index.html.jinja +12 -0
- womm/assets/copier/official/javascript/template/package.json.jinja +88 -0
- womm/assets/copier/official/javascript/template/prettier.config.mjs.jinja +8 -0
- womm/assets/copier/official/javascript/template/src/App.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.tsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/App.vue.jinja +18 -0
- womm/assets/copier/official/javascript/template/src/index.jsx.jinja +10 -0
- womm/assets/copier/official/javascript/template/src/index.tsx.jinja +11 -0
- womm/assets/copier/official/javascript/template/src/main.js.jinja +21 -0
- womm/assets/copier/official/javascript/template/src/main.ts.jinja +21 -0
- womm/assets/copier/official/javascript/template/tsconfig.json.jinja +35 -0
- womm/assets/copier/official/javascript/template/vite.config.mjs.jinja +10 -0
- womm/assets/copier/official/javascript/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +63 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.js.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_tests %}tests{% endif %}/smoke.test.ts.jinja +12 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +4 -0
- womm/assets/copier/official/javascript/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +27 -0
- womm/assets/copier/official/python/copier.yml +107 -0
- womm/assets/copier/official/python/template/.gitignore.jinja +40 -0
- womm/assets/copier/official/python/template/.pre-commit-config.yaml.jinja +19 -0
- womm/assets/copier/official/python/template/.python-version.jinja +1 -0
- womm/assets/copier/official/python/template/README.md.jinja +83 -0
- womm/assets/copier/official/python/template/pyproject.toml.jinja +114 -0
- womm/assets/copier/official/python/template/{% if framework == 'django' %}manage.py{% endif %}.jinja +23 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if not use_src_layout %}{{ package_name }}{% endif %}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/__init__.py.jinja +3 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/asgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/__init__.py.jinja +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/apps.py.jinja +10 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/models.py.jinja +1 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/core/views.py.jinja +8 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/py.typed +0 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/settings.py.jinja +81 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/urls.py.jinja +11 -0
- womm/assets/copier/official/python/template/{% if use_src_layout %}src{% endif %}/{{ package_name }}/wsgi.py.jinja +9 -0
- womm/assets/copier/official/python/template/{% if with_ci %}.github{% endif %}/workflows/ci.yml.jinja +78 -0
- womm/assets/copier/official/python/template/{% if with_tests %}tests{% endif %}/test_smoke.py.jinja +16 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/extensions.json.jinja +8 -0
- womm/assets/copier/official/python/template/{% if with_vscode %}.vscode{% endif %}/settings.json.jinja +28 -0
- womm/bin/refresh_env.cmd +130 -0
- womm/cli.py +111 -0
- womm/commands/__init__.py +30 -0
- womm/commands/core/__init__.py +29 -0
- womm/commands/core/doctor.py +52 -0
- womm/commands/core/path.py +337 -0
- womm/commands/project/__init__.py +31 -0
- womm/commands/project/create.py +128 -0
- womm/commands/project/setup.py +438 -0
- womm/commands/project/template.py +160 -0
- womm/commands/system/__init__.py +31 -0
- womm/commands/system/context/__init__.py +82 -0
- womm/commands/system/context/backup.py +344 -0
- womm/commands/system/context/inventory.py +111 -0
- womm/commands/system/context/registration.py +290 -0
- womm/commands/system/deps.py +165 -0
- womm/commands/system/system.py +130 -0
- womm/exceptions/__init__.py +69 -0
- womm/exceptions/common/__init__.py +55 -0
- womm/exceptions/common/command_service.py +91 -0
- womm/exceptions/common/file_service.py +60 -0
- womm/exceptions/common/security_service.py +44 -0
- womm/exceptions/common/validation_service.py +70 -0
- womm/exceptions/context/__init__.py +27 -0
- womm/exceptions/context/context_service.py +55 -0
- womm/exceptions/project/__init__.py +29 -0
- womm/exceptions/project/project_service.py +59 -0
- womm/exceptions/system/__init__.py +25 -0
- womm/exceptions/system/system_service.py +53 -0
- womm/interfaces/__init__.py +71 -0
- womm/interfaces/context/__init__.py +34 -0
- womm/interfaces/context/menu_interface.py +686 -0
- womm/interfaces/context/registry_interface.py +562 -0
- womm/interfaces/context/script_detector_interface.py +208 -0
- womm/interfaces/context/script_registrar.py +264 -0
- womm/interfaces/core/__init__.py +26 -0
- womm/interfaces/core/doctor_interface.py +102 -0
- womm/interfaces/dependencies/__init__.py +28 -0
- womm/interfaces/dependencies/deps_interface.py +160 -0
- womm/interfaces/project/__init__.py +36 -0
- womm/interfaces/project/create_interface.py +162 -0
- womm/interfaces/project/detection_interface.py +181 -0
- womm/interfaces/project/manager_interface.py +99 -0
- womm/interfaces/project/setup_interface.py +477 -0
- womm/interfaces/project/template_store_interface.py +196 -0
- womm/interfaces/system/__init__.py +32 -0
- womm/interfaces/system/detector_interface.py +84 -0
- womm/interfaces/system/environment_interface.py +110 -0
- womm/interfaces/system/path_interface.py +570 -0
- womm/services/__init__.py +70 -0
- womm/services/common/__init__.py +33 -0
- womm/services/common/base_validation_service.py +450 -0
- womm/services/common/command_runner_service.py +647 -0
- womm/services/common/file_scanner_service.py +483 -0
- womm/services/common/security_validator_service.py +348 -0
- womm/services/context/__init__.py +37 -0
- womm/services/context/backup_entries.py +148 -0
- womm/services/context/parameters.py +515 -0
- womm/services/context/registry_paths.py +56 -0
- womm/services/context/registry_service.py +573 -0
- womm/services/context/validation_service.py +691 -0
- womm/services/dependencies/__init__.py +29 -0
- womm/services/dependencies/probe.py +102 -0
- womm/services/project/__init__.py +48 -0
- womm/services/project/copier_project_creation_service.py +111 -0
- womm/services/project/destination_guard.py +96 -0
- womm/services/project/detection_service.py +354 -0
- womm/services/project/env_utils.py +333 -0
- womm/services/project/javascript_environment_service.py +348 -0
- womm/services/project/python_environment_service.py +245 -0
- womm/services/project/setup_profile_resolver.py +146 -0
- womm/services/project/template_store_service.py +344 -0
- womm/services/project/validation_service.py +418 -0
- womm/services/system/__init__.py +32 -0
- womm/services/system/detector_service.py +704 -0
- womm/services/system/environment_service.py +494 -0
- womm/services/system/path_service.py +642 -0
- womm/shared/__init__.py +30 -0
- womm/shared/configs/__init__.py +51 -0
- womm/shared/configs/context/__init__.py +43 -0
- womm/shared/configs/context/context_config.py +125 -0
- womm/shared/configs/context/context_file_types_config.py +159 -0
- womm/shared/configs/context/context_limits_config.py +187 -0
- womm/shared/configs/context/context_paths_config.py +115 -0
- womm/shared/configs/context/context_types_config.py +65 -0
- womm/shared/configs/context/script_config.py +219 -0
- womm/shared/configs/dependencies/__init__.py +32 -0
- womm/shared/configs/dependencies/runtime_config.py +46 -0
- womm/shared/configs/dependencies/runtime_package_manager_config.py +48 -0
- womm/shared/configs/logging_config.py +89 -0
- womm/shared/configs/project/__init__.py +33 -0
- womm/shared/configs/project/project_config.py +109 -0
- womm/shared/configs/project/project_structure_config.py +88 -0
- womm/shared/configs/project/python_project_config.py +165 -0
- womm/shared/configs/security/__init__.py +26 -0
- womm/shared/configs/security/security_patterns_config.py +242 -0
- womm/shared/configs/system/__init__.py +28 -0
- womm/shared/configs/system/system_detector_config.py +210 -0
- womm/shared/configs/system/system_environment_config.py +101 -0
- womm/shared/models/__init__.py +13 -0
- womm/shared/models/template_source.py +65 -0
- womm/shared/paths.py +192 -0
- womm/shared/results/__init__.py +138 -0
- womm/shared/results/base.py +85 -0
- womm/shared/results/command_results.py +61 -0
- womm/shared/results/context_results.py +345 -0
- womm/shared/results/dependency_results.py +110 -0
- womm/shared/results/doctor_results.py +41 -0
- womm/shared/results/file_results.py +97 -0
- womm/shared/results/project_results.py +163 -0
- womm/shared/results/security_results.py +128 -0
- womm/shared/results/system_results.py +268 -0
- womm/shared/results/template_results.py +43 -0
- womm/shared/runtime.py +36 -0
- womm/ui/__init__.py +31 -0
- womm/ui/common/__init__.py +39 -0
- womm/ui/common/interactive_menu.py +246 -0
- womm/ui/common/logging.py +184 -0
- womm/ui/common/prompts.py +93 -0
- womm/ui/context/__init__.py +31 -0
- womm/ui/context/display.py +485 -0
- womm/ui/context/menu_display.py +189 -0
- womm/ui/context/wizard.py +557 -0
- womm/ui/project/__init__.py +42 -0
- womm/ui/project/create/create_completion_summaries.py +55 -0
- womm/ui/project/project_wizard.py +174 -0
- womm/ui/project/setup/setup_completion_summaries.py +111 -0
- womm/ui/project/templates/template_store_display.py +128 -0
- womm/ui/system/__init__.py +60 -0
- womm/ui/system/display.py +531 -0
- womm/ui/system/path_display.py +387 -0
- womm/utils/__init__.py +23 -0
- womm/utils/common/__init__.py +49 -0
- womm/utils/common/file_scanner_utils.py +110 -0
- womm/utils/common/path_resolver_utils.py +127 -0
- womm/utils/common/safe_fs_utils.py +135 -0
- womm/utils/context/__init__.py +54 -0
- womm/utils/context/core_utils.py +345 -0
- womm/utils/context/icon_utils.py +259 -0
- womm/utils/project/__init__.py +106 -0
- womm/utils/project/asset_utils.py +154 -0
- womm/utils/project/core_utils.py +391 -0
- womm/utils/project/file_utils.py +494 -0
- womm/utils/project/platform_utils.py +170 -0
- womm/utils/project/validation_utils.py +273 -0
- womm/utils/security/__init__.py +46 -0
- womm/utils/security/security_validation_utils.py +258 -0
- womm/utils/system/__init__.py +69 -0
- womm/utils/system/detector_utils.py +299 -0
- womm/utils/system/environment_utils.py +172 -0
- womm/utils/system/path_utils.py +101 -0
- womm_cli-4.0.0.dist-info/METADATA +203 -0
- womm_cli-4.0.0.dist-info/RECORD +218 -0
- womm_cli-4.0.0.dist-info/WHEEL +4 -0
- womm_cli-4.0.0.dist-info/entry_points.txt +2 -0
- womm_cli-4.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONFIGS - Configuration Modules
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Configuration modules for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package contains configuration classes organized by domain:
|
|
11
|
+
- dependencies: Runtimes and runtime package managers
|
|
12
|
+
- project: Project structure and types
|
|
13
|
+
- system: System detection and environment
|
|
14
|
+
- context: Context menu configuration
|
|
15
|
+
- security: Security patterns
|
|
16
|
+
- scanner: File scanner configuration
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# IMPORTS
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# Local imports
|
|
25
|
+
from .context import ContextConfig
|
|
26
|
+
from .dependencies import RuntimeConfig, RuntimePackageManagerConfig
|
|
27
|
+
from .project import (
|
|
28
|
+
ProjectConfig,
|
|
29
|
+
ProjectStructureConfig,
|
|
30
|
+
PythonProjectConfig,
|
|
31
|
+
)
|
|
32
|
+
from .security import FileScannerConfig, SecurityPatternsConfig
|
|
33
|
+
from .system import PackageManagerConfig, SystemDetectorConfig, SystemEnvironmentConfig
|
|
34
|
+
|
|
35
|
+
# ///////////////////////////////////////////////////////////////
|
|
36
|
+
# PUBLIC API
|
|
37
|
+
# ///////////////////////////////////////////////////////////////
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"ContextConfig",
|
|
41
|
+
"FileScannerConfig",
|
|
42
|
+
"PackageManagerConfig",
|
|
43
|
+
"ProjectConfig",
|
|
44
|
+
"ProjectStructureConfig",
|
|
45
|
+
"PythonProjectConfig",
|
|
46
|
+
"RuntimeConfig",
|
|
47
|
+
"RuntimePackageManagerConfig",
|
|
48
|
+
"SecurityPatternsConfig",
|
|
49
|
+
"SystemDetectorConfig",
|
|
50
|
+
"SystemEnvironmentConfig",
|
|
51
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT CONFIGS - Context Configuration Modules
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Context configuration modules for Works On My Machine.
|
|
9
|
+
|
|
10
|
+
This package contains configuration classes for:
|
|
11
|
+
- Context paths (registry paths, command parameters)
|
|
12
|
+
- Context limits (validation, extensions, patterns)
|
|
13
|
+
- Context file types (file type extension mappings)
|
|
14
|
+
- Context types (type constants)
|
|
15
|
+
- Script and icon configuration
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# IMPORTS
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
# Local imports
|
|
24
|
+
from .context_config import ContextConfig
|
|
25
|
+
from .context_file_types_config import ContextFileTypesConfig
|
|
26
|
+
from .context_limits_config import ContextLimitsConfig
|
|
27
|
+
from .context_paths_config import ContextPathsConfig
|
|
28
|
+
from .context_types_config import ContextTypesConfig
|
|
29
|
+
from .script_config import IconConfig, ScriptConfig
|
|
30
|
+
|
|
31
|
+
# ///////////////////////////////////////////////////////////////
|
|
32
|
+
# PUBLIC API
|
|
33
|
+
# ///////////////////////////////////////////////////////////////
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"ContextConfig",
|
|
37
|
+
"ContextFileTypesConfig",
|
|
38
|
+
"ContextLimitsConfig",
|
|
39
|
+
"ContextPathsConfig",
|
|
40
|
+
"ContextTypesConfig",
|
|
41
|
+
"IconConfig",
|
|
42
|
+
"ScriptConfig",
|
|
43
|
+
]
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT CONFIG - Context Menu Configuration Facade
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Facade configuration for context menu operations.
|
|
9
|
+
|
|
10
|
+
This module re-exports context configuration from specialized modules
|
|
11
|
+
for backward compatibility. New code should import directly from:
|
|
12
|
+
- context_paths_config.py - Registry paths and command parameters
|
|
13
|
+
- context_limits_config.py - Validation limits, patterns, extensions
|
|
14
|
+
- context_file_types_config.py - File type extension mappings
|
|
15
|
+
- context_types_config.py - Context type constants
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# IMPORTS
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
# Standard library imports
|
|
24
|
+
import re
|
|
25
|
+
from dataclasses import dataclass
|
|
26
|
+
from typing import ClassVar
|
|
27
|
+
|
|
28
|
+
# Local imports - Re-export for backward compatibility
|
|
29
|
+
from .context_file_types_config import ContextFileTypesConfig
|
|
30
|
+
from .context_limits_config import ContextLimitsConfig
|
|
31
|
+
from .context_paths_config import ContextPathsConfig
|
|
32
|
+
|
|
33
|
+
# ///////////////////////////////////////////////////////////////
|
|
34
|
+
# FACADE CLASS DEFINITION
|
|
35
|
+
# ///////////////////////////////////////////////////////////////
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class ContextConfig:
|
|
40
|
+
"""Context menu configuration facade (backward compatibility).
|
|
41
|
+
|
|
42
|
+
This class aggregates context configuration from specialized modules.
|
|
43
|
+
For new code, prefer importing directly from:
|
|
44
|
+
- ContextPathsConfig: Registry paths, command parameters
|
|
45
|
+
- ContextLimitsConfig: Validation limits, patterns, extensions
|
|
46
|
+
- ContextFileTypesConfig: File type extension mappings
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
# ///////////////////////////////////////////////////////////
|
|
50
|
+
# REGISTRY PATTERNS (from ContextLimitsConfig)
|
|
51
|
+
# ///////////////////////////////////////////////////////////
|
|
52
|
+
|
|
53
|
+
REGISTRY_KEY_PATTERN: ClassVar[re.Pattern[str]] = (
|
|
54
|
+
ContextLimitsConfig.REGISTRY_KEY_PATTERN
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# ///////////////////////////////////////////////////////////
|
|
58
|
+
# VALID EXTENSIONS (from ContextLimitsConfig)
|
|
59
|
+
# ///////////////////////////////////////////////////////////
|
|
60
|
+
|
|
61
|
+
VALID_SCRIPT_EXTENSIONS: ClassVar[set[str]] = (
|
|
62
|
+
ContextLimitsConfig.VALID_SCRIPT_EXTENSIONS
|
|
63
|
+
)
|
|
64
|
+
VALID_ICON_EXTENSIONS: ClassVar[set[str]] = (
|
|
65
|
+
ContextLimitsConfig.VALID_ICON_EXTENSIONS
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# ///////////////////////////////////////////////////////////
|
|
69
|
+
# MAXIMUM LENGTHS (from ContextLimitsConfig)
|
|
70
|
+
# ///////////////////////////////////////////////////////////
|
|
71
|
+
|
|
72
|
+
MAX_LABEL_LENGTH: ClassVar[int] = ContextLimitsConfig.MAX_LABEL_LENGTH
|
|
73
|
+
MAX_REGISTRY_KEY_LENGTH: ClassVar[int] = ContextLimitsConfig.MAX_REGISTRY_KEY_LENGTH
|
|
74
|
+
MAX_PATH_LENGTH: ClassVar[int] = ContextLimitsConfig.MAX_PATH_LENGTH
|
|
75
|
+
MAX_ICON_FILE_SIZE: ClassVar[int] = ContextLimitsConfig.MAX_ICON_FILE_SIZE
|
|
76
|
+
|
|
77
|
+
# ///////////////////////////////////////////////////////////
|
|
78
|
+
# REGISTRY PATHS (from ContextPathsConfig)
|
|
79
|
+
# ///////////////////////////////////////////////////////////
|
|
80
|
+
|
|
81
|
+
CONTEXT_PATHS: ClassVar[dict[str, str]] = ContextPathsConfig.CONTEXT_PATHS
|
|
82
|
+
REGISTRY_PATHS_BY_TYPE: ClassVar[dict[str, str]] = (
|
|
83
|
+
ContextPathsConfig.REGISTRY_PATHS_BY_TYPE
|
|
84
|
+
)
|
|
85
|
+
COMMAND_PARAMETERS: ClassVar[dict[str, str]] = ContextPathsConfig.COMMAND_PARAMETERS
|
|
86
|
+
|
|
87
|
+
# ///////////////////////////////////////////////////////////
|
|
88
|
+
# FILE TYPE EXTENSIONS (from ContextFileTypesConfig)
|
|
89
|
+
# ///////////////////////////////////////////////////////////
|
|
90
|
+
|
|
91
|
+
FILE_TYPE_EXTENSIONS: ClassVar[dict[str, set[str]]] = (
|
|
92
|
+
ContextFileTypesConfig.FILE_TYPE_EXTENSIONS
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# ///////////////////////////////////////////////////////////
|
|
96
|
+
# RESERVED NAMES (from ContextLimitsConfig)
|
|
97
|
+
# ///////////////////////////////////////////////////////////
|
|
98
|
+
|
|
99
|
+
RESERVED_REGISTRY_NAMES: ClassVar[set[str]] = (
|
|
100
|
+
ContextLimitsConfig.RESERVED_REGISTRY_NAMES
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# ///////////////////////////////////////////////////////////
|
|
104
|
+
# INVALID CHARACTERS (from ContextLimitsConfig)
|
|
105
|
+
# ///////////////////////////////////////////////////////////
|
|
106
|
+
|
|
107
|
+
INVALID_LABEL_CHARS: ClassVar[list[str]] = ContextLimitsConfig.INVALID_LABEL_CHARS
|
|
108
|
+
|
|
109
|
+
# ///////////////////////////////////////////////////////////
|
|
110
|
+
# SPECIAL ICON VALUES (from ContextLimitsConfig)
|
|
111
|
+
# ///////////////////////////////////////////////////////////
|
|
112
|
+
|
|
113
|
+
SPECIAL_ICON_VALUES: ClassVar[set[str]] = ContextLimitsConfig.SPECIAL_ICON_VALUES
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# ///////////////////////////////////////////////////////////////
|
|
117
|
+
# PUBLIC API
|
|
118
|
+
# ///////////////////////////////////////////////////////////////
|
|
119
|
+
|
|
120
|
+
__all__ = [
|
|
121
|
+
"ContextConfig",
|
|
122
|
+
"ContextFileTypesConfig",
|
|
123
|
+
"ContextLimitsConfig",
|
|
124
|
+
"ContextPathsConfig",
|
|
125
|
+
]
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT FILE TYPES CONFIG - File Type Extensions
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Configuration for context menu file type extensions.
|
|
9
|
+
|
|
10
|
+
This config class exposes file type extension mappings used by
|
|
11
|
+
context menu utilities for file categorization.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from typing import ClassVar
|
|
22
|
+
|
|
23
|
+
# ///////////////////////////////////////////////////////////////
|
|
24
|
+
# CLASS DEFINITION
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class ContextFileTypesConfig:
|
|
30
|
+
"""Context menu file types configuration (static, read-only).
|
|
31
|
+
|
|
32
|
+
Contains file extension mappings for different file categories
|
|
33
|
+
used in context menu operations.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
# ///////////////////////////////////////////////////////////
|
|
37
|
+
# FILE TYPE EXTENSIONS
|
|
38
|
+
# ///////////////////////////////////////////////////////////
|
|
39
|
+
|
|
40
|
+
FILE_TYPE_EXTENSIONS: ClassVar[dict[str, set[str]]] = {
|
|
41
|
+
"image": {
|
|
42
|
+
".jpg",
|
|
43
|
+
".jpeg",
|
|
44
|
+
".png",
|
|
45
|
+
".gif",
|
|
46
|
+
".bmp",
|
|
47
|
+
".tiff",
|
|
48
|
+
".webp",
|
|
49
|
+
".svg",
|
|
50
|
+
".ico",
|
|
51
|
+
},
|
|
52
|
+
"text": {
|
|
53
|
+
".txt",
|
|
54
|
+
".md",
|
|
55
|
+
".py",
|
|
56
|
+
".js",
|
|
57
|
+
".html",
|
|
58
|
+
".css",
|
|
59
|
+
".json",
|
|
60
|
+
".xml",
|
|
61
|
+
".csv",
|
|
62
|
+
".log",
|
|
63
|
+
},
|
|
64
|
+
"archive": {".zip", ".rar", ".7z", ".tar", ".gz", ".bz2", ".xz", ".cab"},
|
|
65
|
+
"document": {
|
|
66
|
+
".pdf",
|
|
67
|
+
".doc",
|
|
68
|
+
".docx",
|
|
69
|
+
".xls",
|
|
70
|
+
".xlsx",
|
|
71
|
+
".ppt",
|
|
72
|
+
".pptx",
|
|
73
|
+
".odt",
|
|
74
|
+
".ods",
|
|
75
|
+
".odp",
|
|
76
|
+
},
|
|
77
|
+
"media": {
|
|
78
|
+
".mp3",
|
|
79
|
+
".mp4",
|
|
80
|
+
".avi",
|
|
81
|
+
".mkv",
|
|
82
|
+
".wav",
|
|
83
|
+
".flac",
|
|
84
|
+
".mov",
|
|
85
|
+
".wmv",
|
|
86
|
+
".flv",
|
|
87
|
+
},
|
|
88
|
+
"code": {
|
|
89
|
+
".py",
|
|
90
|
+
".js",
|
|
91
|
+
".ts",
|
|
92
|
+
".java",
|
|
93
|
+
".cpp",
|
|
94
|
+
".c",
|
|
95
|
+
".h",
|
|
96
|
+
".cs",
|
|
97
|
+
".php",
|
|
98
|
+
".rb",
|
|
99
|
+
".go",
|
|
100
|
+
".rs",
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# ///////////////////////////////////////////////////////////
|
|
105
|
+
# HELPER METHODS
|
|
106
|
+
# ///////////////////////////////////////////////////////////
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def get_file_type(cls, extension: str) -> str | None:
|
|
110
|
+
"""Get the file type for an extension.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
extension: File extension (with dot)
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
File type name or None if not categorized
|
|
117
|
+
"""
|
|
118
|
+
ext_lower = extension.lower()
|
|
119
|
+
for file_type, extensions in cls.FILE_TYPE_EXTENSIONS.items():
|
|
120
|
+
if ext_lower in extensions:
|
|
121
|
+
return file_type
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
@classmethod
|
|
125
|
+
def get_extensions_for_type(cls, file_type: str) -> set[str]:
|
|
126
|
+
"""Get extensions for a file type.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
file_type: File type name (image, text, archive, etc.)
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
Set of extensions or empty set if type not found
|
|
133
|
+
"""
|
|
134
|
+
return cls.FILE_TYPE_EXTENSIONS.get(file_type, set())
|
|
135
|
+
|
|
136
|
+
@classmethod
|
|
137
|
+
def get_all_file_types(cls) -> list[str]:
|
|
138
|
+
"""Get all available file types.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
List of file type names
|
|
142
|
+
"""
|
|
143
|
+
return list(cls.FILE_TYPE_EXTENSIONS.keys())
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
def get_all_extensions(cls) -> dict[str, set[str]]:
|
|
147
|
+
"""Get a copy of all file type extensions.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Copy of FILE_TYPE_EXTENSIONS dict
|
|
151
|
+
"""
|
|
152
|
+
return cls.FILE_TYPE_EXTENSIONS.copy()
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# ///////////////////////////////////////////////////////////////
|
|
156
|
+
# PUBLIC API
|
|
157
|
+
# ///////////////////////////////////////////////////////////////
|
|
158
|
+
|
|
159
|
+
__all__ = ["ContextFileTypesConfig"]
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# CONTEXT LIMITS CONFIG - Validation Limits & Extensions
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Configuration for context menu validation limits and extensions.
|
|
9
|
+
|
|
10
|
+
This config class exposes validation constants used by
|
|
11
|
+
context menu services for input validation.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
# ///////////////////////////////////////////////////////////////
|
|
17
|
+
# IMPORTS
|
|
18
|
+
# ///////////////////////////////////////////////////////////////
|
|
19
|
+
# Standard library imports
|
|
20
|
+
import re
|
|
21
|
+
from dataclasses import dataclass
|
|
22
|
+
from typing import ClassVar
|
|
23
|
+
|
|
24
|
+
# ///////////////////////////////////////////////////////////////
|
|
25
|
+
# CLASS DEFINITION
|
|
26
|
+
# ///////////////////////////////////////////////////////////////
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class ContextLimitsConfig:
|
|
31
|
+
"""Context menu validation limits configuration (static, read-only).
|
|
32
|
+
|
|
33
|
+
Contains validation patterns, limits, and allowed extensions
|
|
34
|
+
for context menu operations.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
# ///////////////////////////////////////////////////////////
|
|
38
|
+
# REGISTRY PATTERNS
|
|
39
|
+
# ///////////////////////////////////////////////////////////
|
|
40
|
+
|
|
41
|
+
REGISTRY_KEY_PATTERN: ClassVar[re.Pattern[str]] = re.compile(r"^[a-zA-Z0-9_\-\.]+$")
|
|
42
|
+
|
|
43
|
+
# ///////////////////////////////////////////////////////////
|
|
44
|
+
# VALID EXTENSIONS
|
|
45
|
+
# ///////////////////////////////////////////////////////////
|
|
46
|
+
|
|
47
|
+
VALID_SCRIPT_EXTENSIONS: ClassVar[set[str]] = {
|
|
48
|
+
".py",
|
|
49
|
+
".ps1",
|
|
50
|
+
".bat",
|
|
51
|
+
".cmd",
|
|
52
|
+
".exe",
|
|
53
|
+
".msi",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
VALID_ICON_EXTENSIONS: ClassVar[set[str]] = {
|
|
57
|
+
".ico",
|
|
58
|
+
".exe",
|
|
59
|
+
".dll",
|
|
60
|
+
".png",
|
|
61
|
+
".jpg",
|
|
62
|
+
".jpeg",
|
|
63
|
+
".bmp",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# ///////////////////////////////////////////////////////////
|
|
67
|
+
# MAXIMUM LENGTHS
|
|
68
|
+
# ///////////////////////////////////////////////////////////
|
|
69
|
+
|
|
70
|
+
MAX_LABEL_LENGTH: ClassVar[int] = 256
|
|
71
|
+
MAX_REGISTRY_KEY_LENGTH: ClassVar[int] = 255
|
|
72
|
+
MAX_PATH_LENGTH: ClassVar[int] = 260
|
|
73
|
+
MAX_ICON_FILE_SIZE: ClassVar[int] = 10 * 1024 * 1024 # 10MB
|
|
74
|
+
|
|
75
|
+
# ///////////////////////////////////////////////////////////
|
|
76
|
+
# RESERVED NAMES
|
|
77
|
+
# ///////////////////////////////////////////////////////////
|
|
78
|
+
|
|
79
|
+
RESERVED_REGISTRY_NAMES: ClassVar[set[str]] = {
|
|
80
|
+
"con",
|
|
81
|
+
"prn",
|
|
82
|
+
"aux",
|
|
83
|
+
"nul",
|
|
84
|
+
"com1",
|
|
85
|
+
"com2",
|
|
86
|
+
"com3",
|
|
87
|
+
"com4",
|
|
88
|
+
"com5",
|
|
89
|
+
"com6",
|
|
90
|
+
"com7",
|
|
91
|
+
"com8",
|
|
92
|
+
"com9",
|
|
93
|
+
"lpt1",
|
|
94
|
+
"lpt2",
|
|
95
|
+
"lpt3",
|
|
96
|
+
"lpt4",
|
|
97
|
+
"lpt5",
|
|
98
|
+
"lpt6",
|
|
99
|
+
"lpt7",
|
|
100
|
+
"lpt8",
|
|
101
|
+
"lpt9",
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
# ///////////////////////////////////////////////////////////
|
|
105
|
+
# INVALID CHARACTERS
|
|
106
|
+
# ///////////////////////////////////////////////////////////
|
|
107
|
+
|
|
108
|
+
INVALID_LABEL_CHARS: ClassVar[list[str]] = [
|
|
109
|
+
"<",
|
|
110
|
+
">",
|
|
111
|
+
":",
|
|
112
|
+
'"',
|
|
113
|
+
"|",
|
|
114
|
+
"?",
|
|
115
|
+
"*",
|
|
116
|
+
"\\",
|
|
117
|
+
"/",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
# ///////////////////////////////////////////////////////////
|
|
121
|
+
# SPECIAL ICON VALUES
|
|
122
|
+
# ///////////////////////////////////////////////////////////
|
|
123
|
+
|
|
124
|
+
SPECIAL_ICON_VALUES: ClassVar[set[str]] = {"auto", "default", "none"}
|
|
125
|
+
|
|
126
|
+
# ///////////////////////////////////////////////////////////
|
|
127
|
+
# HELPER METHODS
|
|
128
|
+
# ///////////////////////////////////////////////////////////
|
|
129
|
+
|
|
130
|
+
@classmethod
|
|
131
|
+
def is_valid_registry_key(cls, key: str) -> bool:
|
|
132
|
+
"""Check if a registry key name is valid.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
key: Registry key name to validate
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
True if valid, False otherwise
|
|
139
|
+
"""
|
|
140
|
+
if not key or len(key) > cls.MAX_REGISTRY_KEY_LENGTH:
|
|
141
|
+
return False
|
|
142
|
+
if key.lower() in cls.RESERVED_REGISTRY_NAMES:
|
|
143
|
+
return False
|
|
144
|
+
return bool(cls.REGISTRY_KEY_PATTERN.match(key))
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def is_valid_script_extension(cls, extension: str) -> bool:
|
|
148
|
+
"""Check if a script extension is valid.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
extension: File extension (with dot)
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
True if valid script extension
|
|
155
|
+
"""
|
|
156
|
+
return extension.lower() in cls.VALID_SCRIPT_EXTENSIONS
|
|
157
|
+
|
|
158
|
+
@classmethod
|
|
159
|
+
def is_valid_icon_extension(cls, extension: str) -> bool:
|
|
160
|
+
"""Check if an icon extension is valid.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
extension: File extension (with dot)
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
True if valid icon extension
|
|
167
|
+
"""
|
|
168
|
+
return extension.lower() in cls.VALID_ICON_EXTENSIONS
|
|
169
|
+
|
|
170
|
+
@classmethod
|
|
171
|
+
def has_invalid_label_chars(cls, label: str) -> bool:
|
|
172
|
+
"""Check if a label contains invalid characters.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
label: Label to check
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
True if label contains invalid characters
|
|
179
|
+
"""
|
|
180
|
+
return any(char in label for char in cls.INVALID_LABEL_CHARS)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# ///////////////////////////////////////////////////////////////
|
|
184
|
+
# PUBLIC API
|
|
185
|
+
# ///////////////////////////////////////////////////////////////
|
|
186
|
+
|
|
187
|
+
__all__ = ["ContextLimitsConfig"]
|