"""What every script and every parse of this driver shares: quoting and the JSON quirk.""" from __future__ import annotations from typing import Any # PowerShell accepts these as single-quote delimiters alongside the ASCII one. _PS_SINGLE_QUOTES = ("'", "‘", "’", "‚", "‛") def _as_list(value: Any) -> list[Any]: """Undo ConvertTo-Json unwrapping a one-element array into a bare value.""" if value is None: return [] if isinstance(value, list): return value return [value] def _ps_quote(value: str) -> str: """Quote ``value`` as a PowerShell single-quoted (verbatim) string.""" for q in _PS_SINGLE_QUOTES: value = value.replace(q, q + q) return f"'{value}'"