proj-flow 0.9.4__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proj_flow/__init__.py +6 -1
- proj_flow/api/arg.py +47 -24
- proj_flow/api/ctx.py +43 -23
- proj_flow/api/env.py +65 -2
- proj_flow/api/step.py +3 -5
- proj_flow/{ext/cplusplus/cmake/__version__.py → base/__cmake_version__.py} +5 -0
- proj_flow/base/name_list.py +19 -0
- proj_flow/base/registry.py +23 -3
- proj_flow/cli/__init__.py +1 -1
- proj_flow/cli/argument.py +2 -2
- proj_flow/{flow/dependency.py → dependency.py} +1 -1
- proj_flow/ext/cplusplus/cmake/__init__.py +2 -2
- proj_flow/ext/cplusplus/cmake/steps.py +1 -1
- proj_flow/ext/cplusplus/conan/__init__.py +2 -4
- proj_flow/ext/cplusplus/conan/_conan.py +1 -1
- proj_flow/ext/github/cli.py +2 -11
- proj_flow/ext/github/switches.py +2 -2
- proj_flow/flow/__init__.py +2 -2
- proj_flow/minimal/base.py +1 -0
- proj_flow/minimal/init.py +43 -10
- proj_flow/minimal/run.py +1 -2
- proj_flow/project/__init__.py +11 -0
- proj_flow/project/api.py +51 -0
- proj_flow/project/cplusplus/__init__.py +10 -0
- proj_flow/{ext/cplusplus/cmake/context.py → project/cplusplus/cmake_context.py} +10 -7
- proj_flow/project/cplusplus/conan_context.py +12 -0
- proj_flow/project/cplusplus/project.py +16 -0
- proj_flow/project/data.py +14 -0
- proj_flow/project/interact.py +255 -0
- {proj_flow-0.9.4.dist-info → proj_flow-0.11.0.dist-info}/METADATA +2 -2
- {proj_flow-0.9.4.dist-info → proj_flow-0.11.0.dist-info}/RECORD +34 -28
- proj_flow/flow/init.py +0 -65
- proj_flow/flow/interact.py +0 -134
- {proj_flow-0.9.4.dist-info → proj_flow-0.11.0.dist-info}/WHEEL +0 -0
- {proj_flow-0.9.4.dist-info → proj_flow-0.11.0.dist-info}/entry_points.txt +0 -0
- {proj_flow-0.9.4.dist-info → proj_flow-0.11.0.dist-info}/licenses/LICENSE +0 -0
proj_flow/flow/init.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Marcin Zdun
|
|
2
|
-
# This code is licensed under MIT license (see LICENSE for details)
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
The **proj_flow.flow.init** supports the ``init`` command.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from proj_flow.api import ctx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def _fixup(settings: ctx.SettingsType, key: str, fixup: str, force=False):
|
|
12
|
-
value = settings.get(key, "")
|
|
13
|
-
if value != "" and not force:
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
value = ctx._build_fixup(settings, fixup)
|
|
17
|
-
settings[key] = value
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _get_default(setting: ctx.Setting, settings: ctx.SettingsType):
|
|
21
|
-
value = setting.calc_value(settings)
|
|
22
|
-
if isinstance(value, list):
|
|
23
|
-
return value[0]
|
|
24
|
-
return value
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def all_default():
|
|
28
|
-
settings: ctx.SettingsType = {}
|
|
29
|
-
|
|
30
|
-
for setting in ctx.defaults:
|
|
31
|
-
value = _get_default(setting, settings)
|
|
32
|
-
settings[setting.json_key] = value
|
|
33
|
-
|
|
34
|
-
for setting in ctx.switches:
|
|
35
|
-
value = _get_default(setting, settings)
|
|
36
|
-
settings[setting.json_key] = value
|
|
37
|
-
|
|
38
|
-
return settings
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def fixup(settings: ctx.SettingsType):
|
|
42
|
-
for setting in ctx.hidden:
|
|
43
|
-
value = _get_default(setting, settings)
|
|
44
|
-
if isinstance(value, bool) or value != "":
|
|
45
|
-
settings[setting.json_key] = value
|
|
46
|
-
|
|
47
|
-
for coll in [ctx.defaults, ctx.hidden]:
|
|
48
|
-
for setting in coll:
|
|
49
|
-
_fixup(settings, setting.json_key, setting.fix or "", setting.force_fix)
|
|
50
|
-
del settings["EXT"]
|
|
51
|
-
|
|
52
|
-
result = {}
|
|
53
|
-
for key in settings:
|
|
54
|
-
path = key.split(".")
|
|
55
|
-
path_ctx = result
|
|
56
|
-
for step in path[:-1]:
|
|
57
|
-
if step not in path_ctx or not isinstance(path_ctx[step], dict):
|
|
58
|
-
path_ctx[step] = {}
|
|
59
|
-
path_ctx = path_ctx[step]
|
|
60
|
-
path_ctx[path[-1]] = settings[key]
|
|
61
|
-
return result
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def get_internal(key: str, value: any = None):
|
|
65
|
-
return ctx.internals.get(key, value)
|
proj_flow/flow/interact.py
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2025 Marcin Zdun
|
|
2
|
-
# This code is licensed under MIT license (see LICENSE for details)
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
The **proj_flow.flow.interact** provides initialization context through user
|
|
6
|
-
prompts.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
from dataclasses import dataclass
|
|
10
|
-
from typing import List, Union
|
|
11
|
-
|
|
12
|
-
from prompt_toolkit import prompt as tk_prompt
|
|
13
|
-
from prompt_toolkit.completion import WordCompleter
|
|
14
|
-
from prompt_toolkit.shortcuts import CompleteStyle
|
|
15
|
-
from prompt_toolkit.validation import Validator
|
|
16
|
-
|
|
17
|
-
from proj_flow.api import ctx
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@dataclass
|
|
21
|
-
class _Question:
|
|
22
|
-
key: str
|
|
23
|
-
prompt: str
|
|
24
|
-
value: ctx.Values
|
|
25
|
-
|
|
26
|
-
@classmethod
|
|
27
|
-
def load_default(cls, default: ctx.Setting, previous: ctx.SettingsType):
|
|
28
|
-
value = default.calc_value(previous)
|
|
29
|
-
return cls(default.json_key, default.prompt, value)
|
|
30
|
-
|
|
31
|
-
def interact(self, counter: int, size: int) -> ctx.StrOrBool:
|
|
32
|
-
if isinstance(self.value, str):
|
|
33
|
-
return self._get_str(self.value, counter, size)
|
|
34
|
-
if isinstance(self.value, bool):
|
|
35
|
-
return self._get_flag(self.value, counter, size)
|
|
36
|
-
return self._get_list(self.value, counter, size)
|
|
37
|
-
|
|
38
|
-
@property
|
|
39
|
-
def ps(self):
|
|
40
|
-
return self.prompt or f'"{self.key}"'
|
|
41
|
-
|
|
42
|
-
def _ps(self, default: ctx.Values, counter: int, size: int):
|
|
43
|
-
if default:
|
|
44
|
-
if isinstance(default, str):
|
|
45
|
-
return [
|
|
46
|
-
("", f"[{counter}/{size}] {self.ps} ["),
|
|
47
|
-
("bold", default),
|
|
48
|
-
("", f"]: "),
|
|
49
|
-
]
|
|
50
|
-
if isinstance(default, bool):
|
|
51
|
-
b = "bold"
|
|
52
|
-
n = ""
|
|
53
|
-
on_true = (b if default else n, "yes")
|
|
54
|
-
on_false = (b if not default else n, "no")
|
|
55
|
-
return [
|
|
56
|
-
("", f"[{counter}/{size}] {self.ps} ["),
|
|
57
|
-
on_true,
|
|
58
|
-
("", " / "),
|
|
59
|
-
on_false,
|
|
60
|
-
("", f"]: "),
|
|
61
|
-
]
|
|
62
|
-
return [
|
|
63
|
-
("", f"[{counter}/{size}] {self.ps} ["),
|
|
64
|
-
("bold", default[0]),
|
|
65
|
-
("", f"{''.join(f' / {x}' for x in default[1:])}]: "),
|
|
66
|
-
]
|
|
67
|
-
return f"[{counter}/{size}] {self.ps}: "
|
|
68
|
-
|
|
69
|
-
def _get_str(self, default: str, counter: int, size: int):
|
|
70
|
-
value = tk_prompt(self._ps(default, counter, size))
|
|
71
|
-
if not value:
|
|
72
|
-
value = default
|
|
73
|
-
return value
|
|
74
|
-
|
|
75
|
-
def _get_flag(self, default: bool, counter: int, size: int):
|
|
76
|
-
value = self._tk_prompt(
|
|
77
|
-
default, ["yes", "no", "on", "off", "1", "0"], counter, size
|
|
78
|
-
)
|
|
79
|
-
result = default
|
|
80
|
-
if value:
|
|
81
|
-
result = value.lower() in ["1", "on", "y", "yes"]
|
|
82
|
-
return result
|
|
83
|
-
|
|
84
|
-
def _get_list(self, defaults: List[str], counter: int, size: int):
|
|
85
|
-
value = self._tk_prompt(defaults, defaults, counter, size)
|
|
86
|
-
if not value:
|
|
87
|
-
value = defaults[0]
|
|
88
|
-
return value
|
|
89
|
-
|
|
90
|
-
def _tk_prompt(
|
|
91
|
-
self,
|
|
92
|
-
defaults: Union[bool | List[str]],
|
|
93
|
-
words: List[str],
|
|
94
|
-
counter: int,
|
|
95
|
-
size: int,
|
|
96
|
-
):
|
|
97
|
-
def valid(word: str):
|
|
98
|
-
return word == "" or word in words
|
|
99
|
-
|
|
100
|
-
validator = Validator.from_callable(valid)
|
|
101
|
-
completer = WordCompleter(words)
|
|
102
|
-
return tk_prompt(
|
|
103
|
-
self._ps(defaults, counter, size),
|
|
104
|
-
validator=validator,
|
|
105
|
-
completer=completer,
|
|
106
|
-
complete_while_typing=True,
|
|
107
|
-
complete_style=CompleteStyle.READLINE_LIKE,
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def prompt() -> ctx.SettingsType:
|
|
112
|
-
"""
|
|
113
|
-
Prompts user to provide details of newly-crated project.
|
|
114
|
-
|
|
115
|
-
:returns: Dictionary with answers to all interactive settings and switches.
|
|
116
|
-
"""
|
|
117
|
-
settings: ctx.SettingsType = {}
|
|
118
|
-
|
|
119
|
-
size = len(ctx.defaults) + len(ctx.switches)
|
|
120
|
-
counter = 1
|
|
121
|
-
|
|
122
|
-
for setting in ctx.defaults:
|
|
123
|
-
loaded = _Question.load_default(setting, settings)
|
|
124
|
-
value = loaded.interact(counter, size)
|
|
125
|
-
settings[loaded.key] = value
|
|
126
|
-
counter += 1
|
|
127
|
-
|
|
128
|
-
for setting in ctx.switches:
|
|
129
|
-
loaded = _Question.load_default(setting, settings)
|
|
130
|
-
value = loaded.interact(counter, size)
|
|
131
|
-
settings[loaded.key] = value
|
|
132
|
-
counter += 1
|
|
133
|
-
|
|
134
|
-
return settings
|
|
File without changes
|
|
File without changes
|
|
File without changes
|