Commit 99f62087 by Sébastien Eustace

Add license validation in init command

parent 13dfae49
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
### Added ### Added
- Added support for `packages`, `include` and `exclude` properties. - Added support for `packages`, `include` and `exclude` properties.
- Added license validation in `init` command.
### Changed ### Changed
......
...@@ -26,7 +26,7 @@ class InitCommand(Command): ...@@ -26,7 +26,7 @@ class InitCommand(Command):
""" """
help = """\ help = """\
The <info>init</info> command creates a basic <comment>pyproject.toml</> file in the current directory. The <info>init</info> command creates a basic <comment>pyproject.toml</> file in the current directory.
""" """
def __init__(self): def __init__(self):
...@@ -98,7 +98,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in ...@@ -98,7 +98,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
question = self.create_question( question = self.create_question(
"License [<comment>{}</comment>]: ".format(license), default=license "License [<comment>{}</comment>]: ".format(license), default=license
) )
question.validator = self._validate_license
license = self.ask(question) license = self.ask(question)
question = self.create_question("Compatible Python versions [*]: ", default="*") question = self.create_question("Compatible Python versions [*]: ", default="*")
...@@ -293,6 +293,13 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in ...@@ -293,6 +293,13 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
return author return author
def _validate_license(self, license):
from poetry.spdx import license_by_id
license_by_id(license)
return license
def _get_pool(self): def _get_pool(self):
from poetry.repositories import Pool from poetry.repositories import Pool
from poetry.repositories.pypi_repository import PyPiRepository from poetry.repositories.pypi_repository import PyPiRepository
......
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