f
This commit is contained in:
@@ -243,7 +243,7 @@ def _title_from_url(url: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _normalise_format(fmt: Optional[str]) -> str:
|
||||
def _normalize_format(fmt: Optional[str]) -> str:
|
||||
"""Normalize output format to valid values."""
|
||||
if not fmt:
|
||||
return "webp"
|
||||
@@ -511,7 +511,7 @@ def _archive_url(url: str, timeout: float) -> Tuple[List[str], List[str]]:
|
||||
def _prepare_output_path(options: ScreenshotOptions) -> Path:
|
||||
"""Prepare and validate output path for screenshot."""
|
||||
ensure_directory(options.output_dir)
|
||||
explicit_format = _normalise_format(
|
||||
explicit_format = _normalize_format(
|
||||
options.output_format
|
||||
) if options.output_format else None
|
||||
inferred_format: Optional[str] = None
|
||||
@@ -521,7 +521,7 @@ def _prepare_output_path(options: ScreenshotOptions) -> Path:
|
||||
path = options.output_dir / path
|
||||
suffix = path.suffix.lower()
|
||||
if suffix:
|
||||
inferred_format = _normalise_format(suffix[1:])
|
||||
inferred_format = _normalize_format(suffix[1:])
|
||||
else:
|
||||
stamp = time.strftime("%Y%m%d_%H%M%S")
|
||||
filename = f"{_slugify_url(options.url)}_{stamp}"
|
||||
@@ -595,7 +595,7 @@ def _capture(
|
||||
tool.debug_dump()
|
||||
|
||||
debug("Launching browser...")
|
||||
format_name = _normalise_format(options.output_format)
|
||||
format_name = _normalize_format(options.output_format)
|
||||
headless = options.headless or format_name == "pdf"
|
||||
debug(f"[_capture] Format: {format_name}, Headless: {headless}")
|
||||
|
||||
@@ -758,7 +758,7 @@ def _capture_screenshot(
|
||||
) -> ScreenshotResult:
|
||||
"""Capture a screenshot for the given options."""
|
||||
debug(f"[_capture_screenshot] Preparing capture for {options.url}")
|
||||
requested_format = _normalise_format(options.output_format)
|
||||
requested_format = _normalize_format(options.output_format)
|
||||
destination = _prepare_output_path(options)
|
||||
warnings: List[str] = []
|
||||
|
||||
@@ -972,7 +972,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
# PREPARE SCREENSHOT OPTIONS
|
||||
# ========================================================================
|
||||
|
||||
format_name = _normalise_format(format_value)
|
||||
format_name = _normalize_format(format_value)
|
||||
filtered_selectors = [str(s).strip() for s in selectors if str(s).strip()]
|
||||
manual_target_selectors = filtered_selectors if filtered_selectors else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user