Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions ghmap/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Command-line interface for the GitHub Event Mapping Tool."""

import argparse
from pathlib import Path
from datetime import datetime, timezone
from importlib.resources import files
from pathlib import Path
from typing import Dict, List, Tuple

from .preprocess.event_processor import EventProcessor
from .mapping.action_mapper import ActionMapper
from .mapping.activity_mapper import ActivityMapper
Expand All @@ -15,7 +16,7 @@ def extract_version_info(filename: str) -> Tuple[str, datetime]:
"""Extract platform and version date from mapping filename.

Expected format: {platform}_{type}_{date}.json
Example: github_action_2025-10-08T16:59:23Z.json
Example: github_action_20251008T165923Z.json (ISO 8601 Basic Format)
"""
# Remove .json extension and split
base_name = filename.replace('.json', '')
Expand All @@ -27,8 +28,15 @@ def extract_version_info(filename: str) -> Tuple[str, datetime]:
# Version date is last part (after last underscore)
version_str = parts[-1]

# Parse ISO format date
version_date = datetime.fromisoformat(version_str.replace('Z', '+00:00'))
# Parse ISO 8601 Basic Format: YYYYMMDDTHHMMSSZ
try:
version_date = datetime.strptime(version_str, '%Y%m%dT%H%M%SZ')
version_date = version_date.replace(tzinfo=timezone.utc)
except ValueError as e:
raise ValueError(
f"Invalid timestamp format: {version_str}. "
f"Expected format: YYYYMMDDTHHMMSSZ (e.g., 20251008T165923Z)"
) from e

return platform, version_date

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1094,4 +1094,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -420,4 +420,4 @@
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,4 @@
]
}
]
}
}
Loading