Commit e03c2d24 by Arun Babu Neelicattu Committed by finswimmer

layout: make original toml content optional

parent 258ba299
...@@ -209,7 +209,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the ...@@ -209,7 +209,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
dev_dependencies=dev_requirements, dev_dependencies=dev_requirements,
) )
content = layout_.generate_poetry_content(pyproject) content = layout_.generate_poetry_content(original=pyproject)
if self.io.is_interactive(): if self.io.is_interactive():
self.line("<info>Generated file</info>") self.line("<info>Generated file</info>")
self.line("") self.line("")
......
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Optional
from tomlkit import dumps from tomlkit import dumps
from tomlkit import loads from tomlkit import loads
...@@ -86,7 +87,9 @@ class Layout(object): ...@@ -86,7 +87,9 @@ class Layout(object):
self._write_poetry(path) self._write_poetry(path)
def generate_poetry_content(self, original_toml): # type: ("PyProjectTOML") -> str def generate_poetry_content(
self, original=None
): # type: (Optional["PyProjectTOML"]) -> str
template = POETRY_DEFAULT template = POETRY_DEFAULT
if self._license: if self._license:
template = POETRY_WITH_LICENSE template = POETRY_WITH_LICENSE
...@@ -121,8 +124,8 @@ class Layout(object): ...@@ -121,8 +124,8 @@ class Layout(object):
content = dumps(content) content = dumps(content)
if original_toml.file.exists(): if original and original.file.exists():
content = dumps(original_toml.data) + "\n" + content content = dumps(original.data) + "\n" + content
return content return content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment