From 170e82c854a00aa74250e4114c6ab1b5fbadf292 Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Sat, 4 May 2024 08:05:17 +0000 Subject: [PATCH] Update arg kwargs parsing to support komma-separated lists also --- mkdocs_table_reader_plugin/safe_eval.py | 37 ++++++++++++++++--- setup.py | 2 +- .../mixed_quotation_marks/docs/file.csv | 4 ++ .../mixed_quotation_marks/docs/index.md | 7 ++++ .../fixtures/mixed_quotation_marks/mkdocs.yml | 7 ++++ tests/test_build.py | 15 +++++++- tests/test_kwargs.py | 8 ++++ 7 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 tests/fixtures/mixed_quotation_marks/docs/file.csv create mode 100644 tests/fixtures/mixed_quotation_marks/docs/index.md create mode 100644 tests/fixtures/mixed_quotation_marks/mkdocs.yml diff --git a/mkdocs_table_reader_plugin/safe_eval.py b/mkdocs_table_reader_plugin/safe_eval.py index 71f8959..6d07519 100644 --- a/mkdocs_table_reader_plugin/safe_eval.py +++ b/mkdocs_table_reader_plugin/safe_eval.py @@ -55,7 +55,7 @@ def safe_eval(string): return literal_eval(string) -def parse_argkwarg(string: str): +def parse_argkwarg(input_str: str): """ Parses a string to detect both args and kwargs. @@ -63,18 +63,43 @@ def parse_argkwarg(string: str): https://stackoverflow.com/questions/9305387/string-of-kwargs-to-kwargs Args: - string (str): string with positional and keyword arguments + input_str (str): string with positional and keyword arguments Returns: args[List], kwargs[Dict] """ - - argkwargs = re.split(r"(?