From a94e6a1c35e24f07bbd0d1b180f03f15c88c9458 Mon Sep 17 00:00:00 2001 From: Justin Ross Date: Mon, 30 Dec 2024 11:09:41 -0500 Subject: [PATCH] Update Plano --- external/plano/Makefile | 2 +- external/plano/src/plano/_tests.py | 8 +++++++- external/plano/src/plano/main.py | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/external/plano/Makefile b/external/plano/Makefile index 0ffef0c..28212e5 100644 --- a/external/plano/Makefile +++ b/external/plano/Makefile @@ -58,7 +58,7 @@ docs: coverage: build python -m venv build/venv . build/venv/bin/activate && pip install --force-reinstall dist/ssorj_plano-*-py3-none-any.whl - . build/venv/bin/activate && PYTHONPATH=build/venv/lib/python3.12/site-packages coverage run \ + . build/venv/bin/activate && PYTHONPATH=build/venv/lib/python3.11/site-packages coverage run \ --include build/venv/lib/python\*/site-packages/plano/\*,build/venv/bin/\* \ build/venv/bin/plano-self-test coverage report diff --git a/external/plano/src/plano/_tests.py b/external/plano/src/plano/_tests.py index 54237dc..f7d1c66 100644 --- a/external/plano/src/plano/_tests.py +++ b/external/plano/src/plano/_tests.py @@ -945,11 +945,17 @@ def string_operations(): result = parse_url("http://example.net/index.html") assert result.hostname == "example.net" - append = Appender() + append = StringBuilder() result = append.join() assert result == "" + append("alpha") + append("beta") + result = str(append) + assert result == "alpha\nbeta" + + append.clear() append("abc") append("123") result = append.join() diff --git a/external/plano/src/plano/main.py b/external/plano/src/plano/main.py index a4782b0..12aa8eb 100644 --- a/external/plano/src/plano/main.py +++ b/external/plano/src/plano/main.py @@ -1545,16 +1545,22 @@ def parse_url(url): # A class for building up long strings # -# append = Appender() +# append = StringBuilder() # append("abc") # append() # append("123") -# append.join() -> "abc\n\n123" -class Appender: +# str(append) -> "abc\n\n123" +class StringBuilder: def __init__(self): self._items = list() def __call__(self, item=""): + self.append(item=item) + + def __str__(self): + return self.join() + + def append(self, item=""): assert item is not None self._items.append(str(item))