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,259 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# ICON UTILS - Context Icon Resolution
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Icon resolution for context menu entries.
|
|
9
|
+
|
|
10
|
+
This module provides icon detection, validation, and management for
|
|
11
|
+
context menu entries with automatic icon selection based on file extensions.
|
|
12
|
+
|
|
13
|
+
Pure lookup over :class:`IconConfig` plus filesystem probes; raises stdlib
|
|
14
|
+
exceptions on invalid input, per the utils-layer contract.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# IMPORTS
|
|
21
|
+
# ///////////////////////////////////////////////////////////////
|
|
22
|
+
# Standard library imports
|
|
23
|
+
import logging
|
|
24
|
+
import os
|
|
25
|
+
import shutil
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
from typing import ClassVar
|
|
28
|
+
|
|
29
|
+
# Local imports
|
|
30
|
+
from ...shared.configs.context import IconConfig
|
|
31
|
+
|
|
32
|
+
# ///////////////////////////////////////////////////////////////
|
|
33
|
+
# MAIN CLASS
|
|
34
|
+
# ///////////////////////////////////////////////////////////////
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ContextIconResolver:
|
|
38
|
+
"""Manage icons for context menu entries."""
|
|
39
|
+
|
|
40
|
+
# Use configuration from IconConfig
|
|
41
|
+
EXTENSION_ICONS: ClassVar[dict[str, str | None]] = IconConfig.EXTENSION_ICONS
|
|
42
|
+
SYSTEM_ICONS: ClassVar[dict[str, str | None]] = IconConfig.SYSTEM_ICONS
|
|
43
|
+
SYSTEM_PATHS: ClassVar[list[str]] = IconConfig.SYSTEM_PATHS
|
|
44
|
+
|
|
45
|
+
# ///////////////////////////////////////////////////////////////
|
|
46
|
+
# PUBLIC METHODS
|
|
47
|
+
# ///////////////////////////////////////////////////////////////
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def get_icon_for_extension(cls, extension: str) -> str | None:
|
|
51
|
+
"""
|
|
52
|
+
Get default icon for file extension.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
extension: File extension (e.g., ".py", ".js")
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Icon path or None if not found
|
|
59
|
+
|
|
60
|
+
Raises:
|
|
61
|
+
ValueError: If extension is invalid
|
|
62
|
+
"""
|
|
63
|
+
if not extension:
|
|
64
|
+
raise ValueError("File extension cannot be None or empty")
|
|
65
|
+
|
|
66
|
+
if not isinstance(extension, str):
|
|
67
|
+
raise ValueError(
|
|
68
|
+
f"Extension must be a string, got {type(extension).__name__}"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return cls.EXTENSION_ICONS.get(extension.lower())
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def get_system_icon(cls, icon_name: str) -> str | None:
|
|
75
|
+
"""
|
|
76
|
+
Get system icon by name.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
icon_name: Name of the system icon
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
Icon path or None if not found
|
|
83
|
+
|
|
84
|
+
Raises:
|
|
85
|
+
ValueError: If icon_name is invalid
|
|
86
|
+
"""
|
|
87
|
+
if not icon_name:
|
|
88
|
+
raise ValueError("Icon name cannot be None or empty")
|
|
89
|
+
|
|
90
|
+
if not isinstance(icon_name, str):
|
|
91
|
+
raise ValueError(
|
|
92
|
+
f"Icon name must be a string, got {type(icon_name).__name__}"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return cls.SYSTEM_ICONS.get(icon_name.lower())
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def validate_icon_path(cls, icon_path: str) -> bool:
|
|
99
|
+
"""
|
|
100
|
+
Validate if icon path exists and is accessible.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
icon_path: Path to the icon file
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
True if icon path is valid, False otherwise
|
|
107
|
+
|
|
108
|
+
Raises:
|
|
109
|
+
ValueError: If icon_path is invalid
|
|
110
|
+
"""
|
|
111
|
+
if not icon_path:
|
|
112
|
+
raise ValueError("Icon path cannot be None or empty")
|
|
113
|
+
|
|
114
|
+
if not isinstance(icon_path, str):
|
|
115
|
+
raise ValueError(
|
|
116
|
+
f"Icon path must be a string, got {type(icon_path).__name__}"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Handle icon with index (e.g., "file.exe,0")
|
|
120
|
+
file_path = (
|
|
121
|
+
icon_path.split(IconConfig.ICON_SEPARATOR)[0]
|
|
122
|
+
if IconConfig.ICON_SEPARATOR in icon_path
|
|
123
|
+
else icon_path
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Check if it's a system icon
|
|
127
|
+
if file_path in cls.SYSTEM_ICONS:
|
|
128
|
+
return True
|
|
129
|
+
|
|
130
|
+
# Check if file exists
|
|
131
|
+
if os.path.exists(file_path):
|
|
132
|
+
return True
|
|
133
|
+
|
|
134
|
+
# Try to find in system paths
|
|
135
|
+
for system_path in cls.SYSTEM_PATHS:
|
|
136
|
+
try:
|
|
137
|
+
full_path = os.path.join(system_path, file_path)
|
|
138
|
+
if os.path.exists(full_path):
|
|
139
|
+
return True
|
|
140
|
+
except OSError as e:
|
|
141
|
+
# Log warning but continue checking other paths
|
|
142
|
+
logging.getLogger(__name__).warning(
|
|
143
|
+
f"Failed to check system path {system_path}: {e}"
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return False
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
def resolve_icon(cls, icon_input: str, file_path: str | None = None) -> str | None:
|
|
150
|
+
"""
|
|
151
|
+
Resolve icon from various input formats.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
icon_input: Icon input (auto, system name, or path)
|
|
155
|
+
file_path: Optional file path for auto-detection
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Resolved icon path or None if not found
|
|
159
|
+
|
|
160
|
+
Raises:
|
|
161
|
+
ValueError: If parameters are invalid
|
|
162
|
+
"""
|
|
163
|
+
if icon_input is not None and not isinstance(icon_input, str):
|
|
164
|
+
raise ValueError(
|
|
165
|
+
f"Icon input must be a string, got {type(icon_input).__name__}"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
if file_path is not None and not isinstance(file_path, str):
|
|
169
|
+
raise ValueError(
|
|
170
|
+
f"File path must be a string, got {type(file_path).__name__}"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if not icon_input or icon_input.lower() == IconConfig.SPECIAL_ICON_VALUE_AUTO:
|
|
174
|
+
# Auto-detect based on file extension
|
|
175
|
+
if file_path:
|
|
176
|
+
extension = Path(file_path).suffix.lower()
|
|
177
|
+
return cls.get_icon_for_extension(extension)
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
# Check if it's a system icon name
|
|
181
|
+
try:
|
|
182
|
+
system_icon = cls.get_system_icon(icon_input)
|
|
183
|
+
if system_icon:
|
|
184
|
+
return system_icon
|
|
185
|
+
except ValueError as e:
|
|
186
|
+
# Log warning but continue with other resolution methods
|
|
187
|
+
logging.getLogger(__name__).warning(
|
|
188
|
+
f"Failed to get system icon '{icon_input}': {e}"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Check if it's a valid path
|
|
192
|
+
try:
|
|
193
|
+
if cls.validate_icon_path(icon_input):
|
|
194
|
+
return icon_input
|
|
195
|
+
except (ValueError, OSError) as e:
|
|
196
|
+
# Log warning but continue with system path search
|
|
197
|
+
logging.getLogger(__name__).warning(
|
|
198
|
+
f"Failed to validate icon path '{icon_input}': {e}"
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# Try to find in system paths
|
|
202
|
+
for system_path in cls.SYSTEM_PATHS:
|
|
203
|
+
try:
|
|
204
|
+
full_path = os.path.join(system_path, icon_input)
|
|
205
|
+
if os.path.exists(full_path):
|
|
206
|
+
return full_path
|
|
207
|
+
except OSError as e:
|
|
208
|
+
# Log warning but continue checking other paths
|
|
209
|
+
logging.getLogger(__name__).warning(
|
|
210
|
+
f"Failed to check system path {system_path}: {e}"
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return None
|
|
214
|
+
|
|
215
|
+
@classmethod
|
|
216
|
+
def find_icon_in_path(cls, icon_name: str) -> str | None:
|
|
217
|
+
"""
|
|
218
|
+
Find icon file in system PATH.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
icon_name: Name of the icon file to find
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Full path to icon file or None if not found
|
|
225
|
+
|
|
226
|
+
Raises:
|
|
227
|
+
ValueError: If icon_name is invalid
|
|
228
|
+
"""
|
|
229
|
+
if not icon_name:
|
|
230
|
+
raise ValueError("Icon name cannot be None or empty")
|
|
231
|
+
|
|
232
|
+
if not isinstance(icon_name, str):
|
|
233
|
+
raise ValueError(
|
|
234
|
+
f"Icon name must be a string, got {type(icon_name).__name__}"
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
return shutil.which(icon_name)
|
|
238
|
+
|
|
239
|
+
@classmethod
|
|
240
|
+
def get_available_icons(cls) -> dict[str, str]:
|
|
241
|
+
"""
|
|
242
|
+
Get list of available system icons.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
Dictionary of available system icons
|
|
246
|
+
"""
|
|
247
|
+
return {
|
|
248
|
+
name: path for name, path in cls.SYSTEM_ICONS.items() if path is not None
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@classmethod
|
|
252
|
+
def get_supported_extensions(cls) -> list[str]:
|
|
253
|
+
"""
|
|
254
|
+
Get list of supported file extensions.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
List of supported file extensions
|
|
258
|
+
"""
|
|
259
|
+
return list(cls.EXTENSION_ICONS.keys())
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# PROJECT UTILS - Pure Project Utility Functions
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Pure utility functions for project operations.
|
|
9
|
+
|
|
10
|
+
This package contains stateless utility functions for:
|
|
11
|
+
- Asset management (path resolution, copying)
|
|
12
|
+
- Project detection
|
|
13
|
+
- Project validation
|
|
14
|
+
- Template processing
|
|
15
|
+
- Platform-specific utilities
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
# ///////////////////////////////////////////////////////////////
|
|
21
|
+
# IMPORTS
|
|
22
|
+
# ///////////////////////////////////////////////////////////////
|
|
23
|
+
# Local imports
|
|
24
|
+
from .asset_utils import (
|
|
25
|
+
copy_asset_file,
|
|
26
|
+
copy_assets_directory,
|
|
27
|
+
)
|
|
28
|
+
from .core_utils import (
|
|
29
|
+
analyze_csharp_config,
|
|
30
|
+
analyze_go_config,
|
|
31
|
+
analyze_java_config,
|
|
32
|
+
analyze_javascript_config,
|
|
33
|
+
analyze_python_config,
|
|
34
|
+
analyze_rust_config,
|
|
35
|
+
categorize_directory,
|
|
36
|
+
create_common_structure,
|
|
37
|
+
create_javascript_config_files,
|
|
38
|
+
create_javascript_structure,
|
|
39
|
+
create_python_dev_config_files,
|
|
40
|
+
create_python_requirements_files,
|
|
41
|
+
create_python_structure,
|
|
42
|
+
matches_project_type,
|
|
43
|
+
)
|
|
44
|
+
from .file_utils import (
|
|
45
|
+
create_javascript_source_files,
|
|
46
|
+
create_node_main_files,
|
|
47
|
+
create_python_main_files,
|
|
48
|
+
create_python_test_file,
|
|
49
|
+
create_react_main_files,
|
|
50
|
+
create_vue_main_files,
|
|
51
|
+
)
|
|
52
|
+
from .platform_utils import (
|
|
53
|
+
get_node_paths,
|
|
54
|
+
get_platform_info,
|
|
55
|
+
get_python_paths,
|
|
56
|
+
get_shell_commands,
|
|
57
|
+
)
|
|
58
|
+
from .validation_utils import (
|
|
59
|
+
check_project_name,
|
|
60
|
+
get_validation_summary,
|
|
61
|
+
suggest_project_name,
|
|
62
|
+
validate_project_config,
|
|
63
|
+
validate_project_name,
|
|
64
|
+
validate_project_path,
|
|
65
|
+
validate_project_type,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# ///////////////////////////////////////////////////////////////
|
|
69
|
+
# PUBLIC API
|
|
70
|
+
# ///////////////////////////////////////////////////////////////
|
|
71
|
+
|
|
72
|
+
__all__ = [
|
|
73
|
+
"analyze_csharp_config",
|
|
74
|
+
"analyze_go_config",
|
|
75
|
+
"analyze_java_config",
|
|
76
|
+
"analyze_javascript_config",
|
|
77
|
+
"analyze_python_config",
|
|
78
|
+
"analyze_rust_config",
|
|
79
|
+
"categorize_directory",
|
|
80
|
+
"check_project_name",
|
|
81
|
+
"copy_asset_file",
|
|
82
|
+
"copy_assets_directory",
|
|
83
|
+
"create_common_structure",
|
|
84
|
+
"create_javascript_config_files",
|
|
85
|
+
"create_javascript_source_files",
|
|
86
|
+
"create_javascript_structure",
|
|
87
|
+
"create_node_main_files",
|
|
88
|
+
"create_python_dev_config_files",
|
|
89
|
+
"create_python_main_files",
|
|
90
|
+
"create_python_requirements_files",
|
|
91
|
+
"create_python_structure",
|
|
92
|
+
"create_python_test_file",
|
|
93
|
+
"create_react_main_files",
|
|
94
|
+
"create_vue_main_files",
|
|
95
|
+
"get_node_paths",
|
|
96
|
+
"get_platform_info",
|
|
97
|
+
"get_python_paths",
|
|
98
|
+
"get_shell_commands",
|
|
99
|
+
"get_validation_summary",
|
|
100
|
+
"matches_project_type",
|
|
101
|
+
"suggest_project_name",
|
|
102
|
+
"validate_project_config",
|
|
103
|
+
"validate_project_name",
|
|
104
|
+
"validate_project_path",
|
|
105
|
+
"validate_project_type",
|
|
106
|
+
]
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ///////////////////////////////////////////////////////////////
|
|
3
|
+
# ASSET UTILS - Asset Path Resolution and Copying
|
|
4
|
+
# Project: works-on-my-machine
|
|
5
|
+
# ///////////////////////////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
Pure utility functions for asset management.
|
|
9
|
+
|
|
10
|
+
This module provides stateless functions for:
|
|
11
|
+
- Copying individual asset files
|
|
12
|
+
- Copying asset directories recursively
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
# ///////////////////////////////////////////////////////////////
|
|
18
|
+
# IMPORTS
|
|
19
|
+
# ///////////////////////////////////////////////////////////////
|
|
20
|
+
# Standard library imports
|
|
21
|
+
import logging
|
|
22
|
+
import shutil
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
# ///////////////////////////////////////////////////////////////
|
|
26
|
+
# LOGGER SETUP
|
|
27
|
+
# ///////////////////////////////////////////////////////////////
|
|
28
|
+
|
|
29
|
+
logger = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
# ///////////////////////////////////////////////////////////////
|
|
32
|
+
# ASSET FILE OPERATIONS
|
|
33
|
+
# ///////////////////////////////////////////////////////////////
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def copy_asset_file(
|
|
37
|
+
source: Path,
|
|
38
|
+
target: Path,
|
|
39
|
+
overwrite: bool = False,
|
|
40
|
+
create_parents: bool = True,
|
|
41
|
+
) -> Path:
|
|
42
|
+
"""Copy a single asset file to target location.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
source: Source file path
|
|
46
|
+
target: Target file path
|
|
47
|
+
overwrite: If True, overwrite existing files. If False, skip if exists.
|
|
48
|
+
create_parents: If True, create parent directories if they don't exist
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Path: Path to the copied file (or existing file if skipped)
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
FileNotFoundError: If the source file does not exist
|
|
55
|
+
IsADirectoryError: If the source path is not a file
|
|
56
|
+
OSError: If the copy operation fails
|
|
57
|
+
"""
|
|
58
|
+
# Validate source
|
|
59
|
+
if not source.exists():
|
|
60
|
+
raise FileNotFoundError(f"Source file does not exist: {source}")
|
|
61
|
+
|
|
62
|
+
if not source.is_file():
|
|
63
|
+
raise IsADirectoryError(f"Source path is not a file: {source}")
|
|
64
|
+
|
|
65
|
+
# Check if target exists
|
|
66
|
+
if target.exists() and not overwrite:
|
|
67
|
+
logger.debug(f"Skipping {target} (already exists, overwrite=False)")
|
|
68
|
+
return target
|
|
69
|
+
|
|
70
|
+
# Create parent directories if needed
|
|
71
|
+
if create_parents:
|
|
72
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
73
|
+
|
|
74
|
+
# Copy the file
|
|
75
|
+
shutil.copy2(source, target)
|
|
76
|
+
logger.debug(f"Copied {source} to {target}")
|
|
77
|
+
|
|
78
|
+
return target
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def copy_assets_directory(
|
|
82
|
+
source: Path,
|
|
83
|
+
target: Path,
|
|
84
|
+
overwrite: bool = False,
|
|
85
|
+
exclude_patterns: list[str] | None = None,
|
|
86
|
+
) -> list[Path]:
|
|
87
|
+
"""Copy an asset directory recursively to target location.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
source: Source directory path
|
|
91
|
+
target: Target directory path
|
|
92
|
+
overwrite: If True, overwrite existing files. If False, skip if exists.
|
|
93
|
+
exclude_patterns: Optional list of glob patterns to exclude
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
list[Path]: List of copied file paths (relative to target)
|
|
97
|
+
|
|
98
|
+
Raises:
|
|
99
|
+
FileNotFoundError: If the source directory does not exist
|
|
100
|
+
NotADirectoryError: If the source path is not a directory
|
|
101
|
+
OSError: If the copy operation fails
|
|
102
|
+
"""
|
|
103
|
+
# Validate source
|
|
104
|
+
if not source.exists():
|
|
105
|
+
raise FileNotFoundError(f"Source directory does not exist: {source}")
|
|
106
|
+
|
|
107
|
+
if not source.is_dir():
|
|
108
|
+
raise NotADirectoryError(f"Source path is not a directory: {source}")
|
|
109
|
+
|
|
110
|
+
copied_files = []
|
|
111
|
+
exclude_patterns = exclude_patterns or []
|
|
112
|
+
|
|
113
|
+
# Create target directory
|
|
114
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
115
|
+
|
|
116
|
+
# Copy files recursively
|
|
117
|
+
for item in source.rglob("*"):
|
|
118
|
+
if item.is_file():
|
|
119
|
+
# Check exclude patterns
|
|
120
|
+
relative_path = item.relative_to(source)
|
|
121
|
+
if any(relative_path.match(pattern) for pattern in exclude_patterns):
|
|
122
|
+
logger.debug(f"Excluding {relative_path} (matches pattern)")
|
|
123
|
+
continue
|
|
124
|
+
|
|
125
|
+
# Determine target file path
|
|
126
|
+
target_file = target / relative_path
|
|
127
|
+
|
|
128
|
+
# Skip if exists and overwrite is False
|
|
129
|
+
if target_file.exists() and not overwrite:
|
|
130
|
+
logger.debug(
|
|
131
|
+
f"Skipping {target_file} (already exists, overwrite=False)"
|
|
132
|
+
)
|
|
133
|
+
continue
|
|
134
|
+
|
|
135
|
+
# Create parent directories
|
|
136
|
+
target_file.parent.mkdir(parents=True, exist_ok=True)
|
|
137
|
+
|
|
138
|
+
# Copy the file
|
|
139
|
+
shutil.copy2(item, target_file)
|
|
140
|
+
copied_files.append(target_file)
|
|
141
|
+
logger.debug(f"Copied {item} to {target_file}")
|
|
142
|
+
|
|
143
|
+
logger.info(f"Copied {len(copied_files)} files from {source} to {target}")
|
|
144
|
+
return copied_files
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# ///////////////////////////////////////////////////////////////
|
|
148
|
+
# PUBLIC API
|
|
149
|
+
# ///////////////////////////////////////////////////////////////
|
|
150
|
+
|
|
151
|
+
__all__ = [
|
|
152
|
+
"copy_asset_file",
|
|
153
|
+
"copy_assets_directory",
|
|
154
|
+
]
|