Не уверен, связана ли это с независимой функцией или с извлечением данных в целом — ` [code]def read_file(file_path): if not os.path.exists(file_path): raise FileNotFoundError(f"File not found: {file_path}") with open(file_path, 'r') as file: return file.readlines()
# Parse Baselight data def parse_baselight(data): parsed_frames = [] for line in data: if "" in line: continue components = line.strip().split() if len(components) < 2: continue filename = components[0] frame_data = components[1:] numeric_frames = sorted(set(validate_numeric(frame) for frame in frame_data if validate_numeric(frame))) if numeric_frames: frames = format_frames(numeric_frames) parsed_frames.append((filename, frames)) return parsed_frames
def format_frames(frames): ranges = [] start = frames[0] end = frames[0] for i in range(1, len(frames)): if frames[i] == end + 1: end = frames[i] else: ranges.append(f"{start}-{end}" if start != end else f"{start}") start = frames[i] end = frames[i] ranges.append(f"{start}-{end}" if start != end else f"{start}") return ", ".join(ranges)
def parse_xytech(data): parsed_orders = [] for line in data: if '/' in line: components = line.strip().split('/') location = components[1].strip() workorder = components[-1].strip() parsed_orders.append((location, workorder)) return parsed_orders
def find_matching_ranges(video_length, frame_ranges): matching_ranges = [] fps = 24 video_frames = int(video_length * fps) for frame_range in frame_ranges: if '-' in frame_range: start, end = map(int, frame_range.split('-')) else: start = end = int(frame_range) if start