5
5
from importlib import metadata
6
6
from typing import Callable , Optional , Type , TypeVar
7
7
8
- from cppython .exceptions import ConfigError
9
- from cppython .schema import API , Generator , Interface , Plugin , PyProject
8
+ from cppython_core .exceptions import ConfigError
9
+ from cppython_core .schema import API , Generator , Interface , Plugin , PyProject
10
10
11
11
12
12
class Project (API ):
@@ -16,11 +16,16 @@ class Project(API):
16
16
17
17
def __init__ (self , interface : Interface , pyproject : PyProject ) -> None :
18
18
19
- self .enabled = pyproject . cppython is not None
19
+ self .enabled = False
20
20
21
- if not self . enabled :
21
+ if pyproject . tool is None :
22
22
return
23
23
24
+ if pyproject .tool .cppython is None :
25
+ return
26
+
27
+ self .enabled = True
28
+
24
29
self ._interface = interface
25
30
26
31
PluginType = TypeVar ("PluginType" , bound = Type [Plugin ])
@@ -40,10 +45,10 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool])
40
45
41
46
return None
42
47
43
- plugin_type = find_plugin_type (Generator , lambda name : name == pyproject .cppython .generator )
48
+ plugin_type = find_plugin_type (Generator , lambda name : name == pyproject .tool . cppython .generator )
44
49
45
50
if plugin_type is None :
46
- raise ConfigError (f"No generator plugin with the name '{ pyproject .cppython .generator } ' was found." )
51
+ raise ConfigError (f"No generator plugin with the name '{ pyproject .tool . cppython .generator } ' was found." )
47
52
48
53
generator_data = interface .read_generator_data (plugin_type .data_type ())
49
54
self ._generator = plugin_type (pyproject , generator_data )
@@ -52,11 +57,11 @@ def download(self):
52
57
"""
53
58
Download the generator tooling if required
54
59
"""
55
- if not self ._generator .downloaded ():
60
+ if not self ._generator .generator_downloaded ():
56
61
self ._interface .print (f"Downloading the { self ._generator .name ()} tool" )
57
62
58
63
# TODO: Make async with progress bar
59
- self ._generator .download ()
64
+ self ._generator .download_generator ()
60
65
self ._interface .print ("Download complete" )
61
66
62
67
# API Contract
0 commit comments