"""Selecionar clipes por palavra-chave. Extraído de writer.py — ver fcpxml/writer/__init__.py para o conjunto. """ from typing import List class SelectionMixin: """Selecionar clipes por palavra-chave.""" # SELECTION OPERATIONS # ======================================================================== def select_by_keyword( self, keywords: List[str], match_mode: str = 'any', favorites_only: bool = False, exclude_rejected: bool = True ) -> List[str]: """ Find clips matching keywords. Args: keywords: Keywords to match match_mode: 'any' (OR), 'all' (AND), 'none' (exclude) favorites_only: Only return favorited clips exclude_rejected: Exclude rejected clips Returns: List of matching clip IDs """ matches = [] for clip_id, clip in self.clips.items(): clip_keywords = set() for kw_elem in clip.findall('keyword'): clip_keywords.add(kw_elem.get('value', '')) # Check keyword match keyword_set = set(keywords) if match_mode == 'any': match = bool(clip_keywords & keyword_set) elif match_mode == 'all': match = keyword_set <= clip_keywords elif match_mode == 'none': match = not bool(clip_keywords & keyword_set) else: match = True if match: matches.append(clip_id) return matches # ========================================================================