Ameliore generation doc API

This commit is contained in:
Emmanuel Viennet 2024-07-27 13:28:55 +02:00
parent f87ed3bb68
commit 4824b33358

View File

@ -854,7 +854,13 @@ def _gen_csv_line(doc_line: dict) -> str:
samples: list[str] = doc_line.get("samples", [])
csv_lines: list[str] = []
for sample in samples:
url, content = sample.split(";", maxsplit=1)
fragments = sample.split(";", maxsplit=1)
if len(fragments) == 2:
url, content = fragments
elif len(fragments) == 1:
url, content = fragments[0], ""
else:
raise ValueError(f"Error: sample invalide: {sample}")
csv_line = f'"{entry_name}";"{url}";"{permission}";"{method}";'
if content:
csv_line += f'"{content}"'