""" Parse GSC-specific actions from GeViScope SDK documentation Extracts actions that are specific to GeViScope servers (like Imex) """ import json import re from typing import Dict, List, Any def parse_gsc_actions_reference() -> Dict[str, Any]: """Parse GscActionsReference_EN.txt to extract all GSC actions""" actions_catalog = {} # Read the reference file with open(r'C:\DEV\COPILOT\SOURCES\EXTRACTED_TEXT\CODEX\GeViScope\Additional documentation\GscActionsReference_EN.txt', 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # GSC-specific action classes that don't overlap with base actions # Based on the investigation, Imex is definitely GSC-specific gsc_specific_categories = { 'Imex': 17, # Class ID from documentation } # Define Imex actions based on documentation imex_actions = { 'ImexCapacityFileAutoDeleted': { 'parameters': ['Warning', 'Destination', 'TotalCapacity', 'FreeCapacity', 'AllocatedByImageFile', 'PercentFree', 'PercentAllocated', 'PercentAllocatedByImageFile', 'TotalFileSize', 'NumberOfFiles'], 'description': 'Imex capacity warning: file auto deleted', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 }, 'ImexCapacityOutOfDiskSpace': { 'parameters': ['Warning', 'Destination', 'TotalCapacity', 'FreeCapacity', 'AllocatedByImageFile', 'PercentFree', 'PercentAllocated', 'PercentAllocatedByImageFile'], 'description': 'Imex capacity warning: out of disk space', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 }, 'ImexCapacityWarning': { 'parameters': ['Warning', 'Destination', 'TotalCapacity', 'FreeCapacity', 'AllocatedByImageFile', 'PercentFree', 'PercentAllocated', 'PercentAllocatedByImageFile'], 'description': 'Imex capacity warning: capacity warning', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 }, 'ImexExportEventImage': { 'parameters': ['EventID', 'TypeID', 'Destination', 'FilePath'], 'description': 'Imex export event image', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 }, 'ImexExportImageFromDB': { 'parameters': ['Channel', 'Destination', 'FilePath', 'PictureTime'], 'description': 'Imex export image from database', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 }, 'ImexExportImageFromLiveStream': { 'parameters': ['Channel', 'Destination', 'FilePath'], 'description': 'Imex export image from live stream', 'category': 'Imex', 'required_caption': True, 'supports_delay': True, 'gsc_specific': True, 'action_class': 17 } } actions_catalog.update(imex_actions) return actions_catalog def merge_with_base_catalog(gsc_actions: Dict[str, Any]) -> Dict[str, Any]: """Merge GSC-specific actions with existing base actions catalog""" # Load existing catalog with open(r'C:\DEV\COPILOT\all_actions_catalog.json', 'r', encoding='utf-8') as f: base_catalog = json.load(f) # Add GSC-specific flag to base actions for action_name in base_catalog: if 'gsc_specific' not in base_catalog[action_name]: base_catalog[action_name]['gsc_specific'] = False base_catalog[action_name]['gcore_specific'] = False # Merge GSC actions for action_name, action_data in gsc_actions.items(): if action_name in base_catalog: print(f"WARNING: {action_name} already exists in base catalog") else: base_catalog[action_name] = action_data return base_catalog def main(): print("="*80) print("PARSING GSC-SPECIFIC ACTIONS") print("="*80) print() # Parse GSC actions gsc_actions = parse_gsc_actions_reference() print(f"Parsed {len(gsc_actions)} GSC-specific actions") # Show what was found print("\nGSC-Specific Actions:") for category in ['Imex']: category_actions = [name for name, data in gsc_actions.items() if data.get('category') == category] if category_actions: print(f"\n{category} ({len(category_actions)} actions):") for action in sorted(category_actions): print(f" - {action}") # Merge with base catalog print("\n" + "="*80) print("MERGING WITH BASE CATALOG") print("="*80) complete_catalog = merge_with_base_catalog(gsc_actions) # Count totals total = len(complete_catalog) base_count = sum(1 for a in complete_catalog.values() if not a.get('gsc_specific')) gsc_count = sum(1 for a in complete_catalog.values() if a.get('gsc_specific')) print(f"\nTotal actions: {total}") print(f" Base actions: {base_count}") print(f" GSC-specific: {gsc_count}") # Save updated catalog output_file = r'C:\DEV\COPILOT\all_actions_catalog_with_gsc.json' with open(output_file, 'w', encoding='utf-8') as f: json.dump(complete_catalog, f, indent=2) print(f"\n[OK] Saved to: {output_file}") print("="*80) if __name__ == '__main__': main()