Spaces:
Paused
Paused
File size: 2,666 Bytes
3b9a6b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
from typing import List, Union
from domain import MOCK_PROJECTS
class MockProjectService:
"""Service for handling project-related operations"""
@staticmethod
def show_mock_project_content(project_names: Union[str, List[str]]) -> str:
"""
Display the content of selected mock projects.
Args:
project_names: Single project name or list of project names
Returns:
Formatted content of the selected projects
"""
if not project_names:
return "No projects selected."
# Handle both single string and list of strings
if isinstance(project_names, str):
project_names = [project_names]
content_parts = []
for project_name in project_names:
if project_name in MOCK_PROJECTS:
content_parts.append(
f"=== {project_name.upper()} ===\n\n{MOCK_PROJECTS[project_name]}"
)
else:
content_parts.append(
f"=== {project_name.upper()} ===\n\nProject not found."
)
return (
"\n\n" + "=" * 50 + "\n\n".join(content_parts)
if content_parts
else "No valid projects selected."
)
@staticmethod
def validate_mock_projects(mock_projects: Union[str, List[str]]) -> List[str]:
"""
Validate mock project selections and return list of invalid projects.
Args:
mock_projects: Single project name or list of project names
Returns:
List of invalid project names (empty if all valid)
"""
if not mock_projects:
return []
if isinstance(mock_projects, str):
mock_projects = [mock_projects]
return [p for p in mock_projects if p not in MOCK_PROJECTS]
@staticmethod
def get_mock_project_files(mock_projects: Union[str, List[str]]) -> List[str]:
"""
Get file contents for selected mock projects.
Args:
mock_projects: Single project name or list of project names
Returns:
List of project file contents
"""
if isinstance(mock_projects, str):
mock_projects = [mock_projects]
return [
MOCK_PROJECTS[project]
for project in mock_projects
if project in MOCK_PROJECTS
]
@staticmethod
def get_available_project_names() -> List[str]:
"""
Get list of available mock project names.
Returns:
List of available project names
"""
return list(MOCK_PROJECTS.keys())
|