Skip to content

Commit

Permalink
Update Plano
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Dec 30, 2024
1 parent 75684d3 commit a94e6a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion external/plano/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion external/plano/src/plano/_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 9 additions & 3 deletions external/plano/src/plano/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit a94e6a1

Please sign in to comment.