Skip to content

Commit

Permalink
Update Dependencies (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Behemyth authored Apr 16, 2022
1 parent b9d31c9 commit 9e35682
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
27 changes: 13 additions & 14 deletions cppython/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dataclasses import dataclass
from importlib import metadata
from pathlib import Path
from typing import Any, Type, TypeVar
from xmlrpc.client import Boolean

Expand Down Expand Up @@ -98,7 +99,6 @@ def __init__(
self, configuration: ProjectConfiguration, interface: Interface, pyproject_data: dict[str, Any]
) -> None:

self.enabled = False
self.configuration = configuration

if self.configuration.verbose:
Expand All @@ -113,60 +113,59 @@ def __init__(
return

extended_pyproject_type = builder.generate_model(plugins)
pyproject = extended_pyproject_type(**pyproject_data)
self.pyproject = extended_pyproject_type(**pyproject_data)

if pyproject.tool is None:
if self.pyproject.tool is None:
if self.configuration.verbose:
interface.print("Table [tool] is not defined")
return

if pyproject.tool.cppython is None:
if self.pyproject.tool.cppython is None:
if self.configuration.verbose:
interface.print("Table [tool.cppython] is not defined")
return

self.enabled = True

self._interface = interface
self._generators = builder.create_generators(plugins, pyproject)
self._generators = builder.create_generators(plugins, self.pyproject)

if self.configuration.verbose:
interface.print("CPPython project initialized")

def download(self):
def download(self, path: Path):
"""
Download the generator tooling if required
"""

for generator in self._generators:

if not generator.generator_downloaded():
if not generator.generator_downloaded(path):
self._interface.print(f"Downloading the {generator.name()} tool")

# TODO: Make async with progress bar
generator.download_generator()
generator.download_generator(path)
self._interface.print("Download complete")

# API Contract

def install(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Installing...")
self.download()
self.download(self.pyproject.tool.cppython.install_path)

for generator in self._generators:
generator.install()

def update(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Updating...")

for generator in self._generators:
generator.update()

def build(self) -> None:
if self.enabled:
if self.pyproject.tool and self.pyproject.tool.cppython:
if self.configuration.verbose:
self._interface.print("CPPython: Building...")

Expand Down
21 changes: 11 additions & 10 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ dynamic = ["version"]
requires-python = ">=3.10"

dependencies = [
"click>=8.0.3",
"tomlkit>=0.10.0",
"cppython-core>=0.1.4",
"click>=8.1.2",
"tomlkit>=0.10.1",
"cppython-core>=0.2.1",
"pydantic>=1.9.0",
]

Expand All @@ -40,7 +40,7 @@ test = [
"pytest>=7.1.1",
"pytest-cov>=3.0.0",
"pytest-mock>=3.7.0",
"pytest-cppython>=0.1.0",
"pytest-cppython>=0.1.4",
]

[project.scripts]
Expand Down
11 changes: 8 additions & 3 deletions tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def test_construction(self, mocker: MockerFixture):

interface_mock = mocker.MagicMock()
configuration = ProjectConfiguration()
Project(configuration, interface_mock, default_pyproject.dict())
Project(configuration, interface_mock, default_pyproject.dict(by_alias=True))

def test_download(self):
"""
TODO
"""


class TestBuilder:
Expand Down Expand Up @@ -65,10 +70,10 @@ def test_generator_data_construction(self, mocker: MockerFixture):

model_type = builder.generate_model([generator_type])

project_data = default_pyproject.dict()
project_data = default_pyproject.dict(by_alias=True)

mock_data = MockGeneratorData(check=True)
project_data["tool"]["cppython"]["mock"] = mock_data.dict()
project_data["tool"]["cppython"]["mock"] = mock_data.dict(by_alias=True)
result = model_type(**project_data)

assert result.tool is not None
Expand Down

0 comments on commit 9e35682

Please sign in to comment.