refactor: _shared.py vira subpacote, um módulo por papel
Eram 882 linhas de seis papéis sem relação, sob um nome que só dizia
"compartilhado" — o depósito onde tudo que servia a mais de um handler
acabava caindo.
media 316 transcrição em cache, corte por fala, relatório
paths 206 sandbox, limites, caminho de saída
project 116 abrir projeto, preparar modifier/generator
captions 112 SRT, VTT, listas com timestamp
detection 99 flash frames, buracos, duplicados
formatting 86 tabelas e relatórios dos handlers
O __init__ reexporta os 46 nomes, então os treze pontos que importam daqui
não mudaram.
_transcript_cut_report saiu de formatting para media: ele precisa do hint de
instalação e do _text_result, ou seja, é relatório de transcrição e não
formatação genérica — mover foi mais honesto que cruzar imports entre os
dois módulos.
Quatro testes patchavam `server_tools._shared.transcribe`; o nome agora é
ligado por _shared/media.py, então o patch passou a apontar para lá — mesmo
padrão da experiência #23.
Lint zerado, 1454 testes passando.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
368bb62706
commit
ffaebb3f72
@@ -0,0 +1,124 @@
|
||||
"""Shared internal helpers used by tool handlers across categories.
|
||||
|
||||
Extracted from server.py — validation, formatting, and small parsing utilities
|
||||
that more than one server_tools/*.py module needs.
|
||||
|
||||
Eram 882 linhas de seis papéis diferentes sob um nome que só dizia
|
||||
"compartilhado". Cada papel virou um módulo; este pacote reexporta tudo, então
|
||||
os treze pontos que importam daqui seguem iguais.
|
||||
|
||||
paths validação contra a sandbox, limites, caminho de saída
|
||||
formatting tabelas e relatórios devolvidos pelos handlers
|
||||
project abrir projeto, preparar modifier/generator
|
||||
captions SRT, VTT e listas com timestamp
|
||||
detection flash frames, buracos, duplicados
|
||||
media transcrição em cache, corte por fala, ações posicionadas
|
||||
"""
|
||||
|
||||
from .captions import (
|
||||
_extract_subtitle_blocks,
|
||||
_parse_timestamp_parts,
|
||||
_raw_markers_to_batch,
|
||||
parse_srt,
|
||||
parse_transcript_timestamps,
|
||||
parse_vtt,
|
||||
)
|
||||
from .detection import (
|
||||
_detect_duplicate_groups,
|
||||
_detect_flash_frames,
|
||||
_detect_gaps,
|
||||
)
|
||||
from .formatting import (
|
||||
_fmt_suggestions,
|
||||
_format_batch_result,
|
||||
_format_clip_table,
|
||||
_markdown_table,
|
||||
_speaker_table,
|
||||
_voice_analysis_config_text,
|
||||
format_duration,
|
||||
format_timecode,
|
||||
)
|
||||
from .media import (
|
||||
_DIARIZATION_INSTALL_HINT,
|
||||
_FEATURES_INSTALL_HINT,
|
||||
_TRANSCRIBE_INSTALL_HINT,
|
||||
AUDIO_MEDIA_EXTENSIONS,
|
||||
TRANSCRIBE_MAX_MEDIA,
|
||||
_apply_placed_action,
|
||||
_cut_transcript_spans,
|
||||
_load_or_transcribe,
|
||||
_transcript_cut_report,
|
||||
_transcript_json_path,
|
||||
)
|
||||
from .paths import (
|
||||
_MAX_JSON_DEPTH,
|
||||
_SANDBOX_ENABLED,
|
||||
MAX_FILE_SIZE,
|
||||
MAX_MEDIA_FILE_SIZE,
|
||||
PROJECTS_DIR,
|
||||
_check_json_depth,
|
||||
_resolve_io_paths,
|
||||
_validate_directory,
|
||||
_validate_filepath,
|
||||
_validate_output_path,
|
||||
find_fcpxml_files,
|
||||
generate_output_path,
|
||||
)
|
||||
from .project import (
|
||||
_no_timeline,
|
||||
_NoTimelineError,
|
||||
_parse_project,
|
||||
_require_timeline,
|
||||
_setup_generator,
|
||||
_setup_modifier,
|
||||
_text_result,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"AUDIO_MEDIA_EXTENSIONS",
|
||||
"MAX_FILE_SIZE",
|
||||
"MAX_MEDIA_FILE_SIZE",
|
||||
"PROJECTS_DIR",
|
||||
"TRANSCRIBE_MAX_MEDIA",
|
||||
"_DIARIZATION_INSTALL_HINT",
|
||||
"_FEATURES_INSTALL_HINT",
|
||||
"_MAX_JSON_DEPTH",
|
||||
"_NoTimelineError",
|
||||
"_SANDBOX_ENABLED",
|
||||
"_TRANSCRIBE_INSTALL_HINT",
|
||||
"_apply_placed_action",
|
||||
"_check_json_depth",
|
||||
"_cut_transcript_spans",
|
||||
"_detect_duplicate_groups",
|
||||
"_detect_flash_frames",
|
||||
"_detect_gaps",
|
||||
"_extract_subtitle_blocks",
|
||||
"_fmt_suggestions",
|
||||
"_format_batch_result",
|
||||
"_format_clip_table",
|
||||
"_load_or_transcribe",
|
||||
"_markdown_table",
|
||||
"_no_timeline",
|
||||
"_parse_project",
|
||||
"_parse_timestamp_parts",
|
||||
"_raw_markers_to_batch",
|
||||
"_require_timeline",
|
||||
"_resolve_io_paths",
|
||||
"_setup_generator",
|
||||
"_setup_modifier",
|
||||
"_speaker_table",
|
||||
"_text_result",
|
||||
"_transcript_cut_report",
|
||||
"_transcript_json_path",
|
||||
"_validate_directory",
|
||||
"_validate_filepath",
|
||||
"_validate_output_path",
|
||||
"_voice_analysis_config_text",
|
||||
"find_fcpxml_files",
|
||||
"format_duration",
|
||||
"format_timecode",
|
||||
"generate_output_path",
|
||||
"parse_srt",
|
||||
"parse_transcript_timestamps",
|
||||
"parse_vtt",
|
||||
]
|
||||
Reference in New Issue
Block a user