code/source: remove unused method Source.putaround()

This commit is contained in:
Ran Benita 2020-07-01 20:20:11 +03:00
parent a7303b52db
commit 4a27d7d973
2 changed files with 0 additions and 46 deletions

View File

@ -89,19 +89,6 @@ class Source:
source.lines[:] = self.lines[start:end]
return source
def putaround(
self, before: str = "", after: str = "", indent: str = " " * 4
) -> "Source":
""" return a copy of the source object with
'before' and 'after' wrapped around it.
"""
beforesource = Source(before)
aftersource = Source(after)
newsource = Source()
lines = [(indent + line) for line in self.lines]
newsource.lines = beforesource.lines + lines + aftersource.lines
return newsource
def indent(self, indent: str = " " * 4) -> "Source":
""" return a copy of the source object with
all lines indented by the given indent-string.

View File

@ -69,39 +69,6 @@ def test_source_from_inner_function() -> None:
assert str(source).startswith("def f():")
def test_source_putaround_simple() -> None:
source = Source("raise ValueError")
source = source.putaround(
"try:",
"""\
except ValueError:
x = 42
else:
x = 23""",
)
assert (
str(source)
== """\
try:
raise ValueError
except ValueError:
x = 42
else:
x = 23"""
)
def test_source_putaround() -> None:
source = Source()
source = source.putaround(
"""
if 1:
x=1
"""
)
assert str(source).strip() == "if 1:\n x=1"
def test_source_strips() -> None:
source = Source("")
assert source == Source()