dsw-tdk 3.13.0__py3-none-any.whl → 4.27.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.
- {dsw_tdk → dsw/tdk}/__init__.py +16 -15
- dsw/tdk/__main__.py +5 -0
- dsw/tdk/api_client.py +407 -0
- dsw/tdk/build_info.py +17 -0
- dsw/tdk/cli.py +708 -0
- dsw/tdk/config.py +151 -0
- dsw/tdk/consts.py +25 -0
- dsw/tdk/core.py +565 -0
- {dsw_tdk → dsw/tdk}/model.py +468 -422
- dsw/tdk/py.typed +0 -0
- dsw/tdk/templates/LICENSE.j2 +1 -0
- {dsw_tdk → dsw/tdk}/templates/README.md.j2 +13 -13
- dsw/tdk/templates/env.j2 +3 -0
- {dsw_tdk → dsw/tdk}/templates/starter.j2 +13 -14
- {dsw_tdk → dsw/tdk}/utils.py +198 -173
- dsw/tdk/validation.py +290 -0
- {dsw_tdk-3.13.0.dist-info → dsw_tdk-4.27.0.dist-info}/METADATA +28 -33
- dsw_tdk-4.27.0.dist-info/RECORD +20 -0
- {dsw_tdk-3.13.0.dist-info → dsw_tdk-4.27.0.dist-info}/WHEEL +1 -2
- dsw_tdk-4.27.0.dist-info/entry_points.txt +3 -0
- dsw_tdk/__main__.py +0 -3
- dsw_tdk/api_client.py +0 -273
- dsw_tdk/cli.py +0 -412
- dsw_tdk/consts.py +0 -19
- dsw_tdk/core.py +0 -385
- dsw_tdk/validation.py +0 -206
- dsw_tdk-3.13.0.dist-info/LICENSE +0 -201
- dsw_tdk-3.13.0.dist-info/RECORD +0 -17
- dsw_tdk-3.13.0.dist-info/entry_points.txt +0 -3
- dsw_tdk-3.13.0.dist-info/top_level.txt +0 -1
dsw/tdk/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// TODO: fill text of your license ({{ template.license }})
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# {{ template.name }}
|
|
2
|
-
|
|
3
|
-
{{ template.description }}
|
|
4
|
-
|
|
5
|
-
## Changelog
|
|
6
|
-
|
|
7
|
-
### {{ template.version }}
|
|
8
|
-
|
|
9
|
-
- Initial version of {{ template.name }} template
|
|
10
|
-
|
|
11
|
-
## License
|
|
12
|
-
|
|
13
|
-
This template is released under {{ template.license }}. Read the LICENSE file for details.
|
|
1
|
+
# {{ template.name }}
|
|
2
|
+
|
|
3
|
+
{{ template.description }}
|
|
4
|
+
|
|
5
|
+
## Changelog
|
|
6
|
+
|
|
7
|
+
### {{ template.version }}
|
|
8
|
+
|
|
9
|
+
- Initial version of {{ template.name }} template
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
This template is released under {{ template.license }}. Read the LICENSE file for details.
|
dsw/tdk/templates/env.j2
ADDED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
{%- raw -%}
|
|
2
|
-
{# This is the template starter file generated by DSW TDK #}
|
|
3
|
-
{%- set
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
##
|
|
9
|
-
##
|
|
10
|
-
##
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{% endraw %}
|
|
1
|
+
{%- raw -%}
|
|
2
|
+
{# This is the template starter file generated by DSW TDK #}
|
|
3
|
+
{%- set dc = ctx|to_context_obj -%}
|
|
4
|
+
|
|
5
|
+
{#
|
|
6
|
+
##
|
|
7
|
+
## TODO: Write the template
|
|
8
|
+
## SEE: https://jinja.palletsprojects.com/templates/
|
|
9
|
+
##
|
|
10
|
+
## ~~ Happy hacking! ~~
|
|
11
|
+
##
|
|
12
|
+
#}
|
|
13
|
+
{% endraw %}
|
{dsw_tdk → dsw/tdk}/utils.py
RENAMED
|
@@ -1,173 +1,198 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
cls._uuids
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
self.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
self.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
self.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
self.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
self.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
self.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
self.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
self.template.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
1
|
+
import pathlib
|
|
2
|
+
import uuid
|
|
3
|
+
|
|
4
|
+
import jinja2
|
|
5
|
+
|
|
6
|
+
from . import consts
|
|
7
|
+
from .model import Format, PackageFilter, Step, Template, TemplateFile
|
|
8
|
+
from .validation import FormatValidator, StepValidator, TemplateValidator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
TEMPLATES_DIR = pathlib.Path(__file__).parent / 'templates'
|
|
12
|
+
|
|
13
|
+
j2_env = jinja2.Environment(
|
|
14
|
+
loader=jinja2.FileSystemLoader(TEMPLATES_DIR),
|
|
15
|
+
extensions=['jinja2.ext.do'],
|
|
16
|
+
autoescape=True,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class UUIDGen:
|
|
21
|
+
|
|
22
|
+
_uuids: set[uuid.UUID] = set()
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def used(cls) -> set[uuid.UUID]:
|
|
26
|
+
return cls._uuids
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def generate(cls) -> uuid.UUID:
|
|
30
|
+
result = uuid.uuid4()
|
|
31
|
+
while result in cls._uuids:
|
|
32
|
+
result = uuid.uuid4()
|
|
33
|
+
cls._uuids.add(result)
|
|
34
|
+
return result
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FormatSpec:
|
|
38
|
+
|
|
39
|
+
def __init__(self):
|
|
40
|
+
self.format = Format()
|
|
41
|
+
self.step = Step(
|
|
42
|
+
name='jinja',
|
|
43
|
+
options={
|
|
44
|
+
'template': 'template.html.j2',
|
|
45
|
+
'content-type': 'text/html',
|
|
46
|
+
'extension': 'html',
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
self.format.uuid = str(UUIDGen.generate())
|
|
50
|
+
self.format.steps.append(self.step)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def name(self):
|
|
54
|
+
return self.format.name
|
|
55
|
+
|
|
56
|
+
@name.setter
|
|
57
|
+
def name(self, value: str):
|
|
58
|
+
self.format.name = value
|
|
59
|
+
FormatValidator.validate_field(self.format, 'name')
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def content_type(self):
|
|
63
|
+
return self.step.options['content-type']
|
|
64
|
+
|
|
65
|
+
@content_type.setter
|
|
66
|
+
def content_type(self, value: str):
|
|
67
|
+
self.step.options['content-type'] = value
|
|
68
|
+
StepValidator.validate(self.step, 'format')
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def file_extension(self):
|
|
72
|
+
return self.step.options['extension']
|
|
73
|
+
|
|
74
|
+
@file_extension.setter
|
|
75
|
+
def file_extension(self, value: str):
|
|
76
|
+
self.step.options['extension'] = value
|
|
77
|
+
StepValidator.validate(self.step, 'format')
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def filename(self):
|
|
81
|
+
return self.step.options['template']
|
|
82
|
+
|
|
83
|
+
@filename.setter
|
|
84
|
+
def filename(self, value: str):
|
|
85
|
+
self.step.options['template'] = str(pathlib.PurePosixPath(pathlib.Path(value)))
|
|
86
|
+
StepValidator.validate(self.step, 'format')
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class TemplateBuilder:
|
|
90
|
+
|
|
91
|
+
def __init__(self):
|
|
92
|
+
self.template = Template()
|
|
93
|
+
self._formats: list[FormatSpec] = []
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def formats(self) -> list[FormatSpec]:
|
|
97
|
+
return self._formats
|
|
98
|
+
|
|
99
|
+
def _validate_field(self, field_name: str):
|
|
100
|
+
TemplateValidator.validate_field(self.template, field_name)
|
|
101
|
+
|
|
102
|
+
def add_format(self, format_spec: FormatSpec):
|
|
103
|
+
self._formats.append(format_spec)
|
|
104
|
+
self.template.formats.append(format_spec.format)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def name(self):
|
|
108
|
+
return self.template.name
|
|
109
|
+
|
|
110
|
+
@name.setter
|
|
111
|
+
def name(self, value: str):
|
|
112
|
+
self.template.name = value
|
|
113
|
+
self._validate_field('name')
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def template_id(self):
|
|
117
|
+
return self.template.template_id
|
|
118
|
+
|
|
119
|
+
@template_id.setter
|
|
120
|
+
def template_id(self, value: str):
|
|
121
|
+
self.template.template_id = value
|
|
122
|
+
self._validate_field('template_id')
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def organization_id(self):
|
|
126
|
+
return self.template.organization_id
|
|
127
|
+
|
|
128
|
+
@organization_id.setter
|
|
129
|
+
def organization_id(self, value: str):
|
|
130
|
+
self.template.organization_id = value
|
|
131
|
+
self._validate_field('organization_id')
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def version(self):
|
|
135
|
+
return self.template.version
|
|
136
|
+
|
|
137
|
+
@version.setter
|
|
138
|
+
def version(self, value: str):
|
|
139
|
+
self.template.version = value
|
|
140
|
+
self._validate_field('version')
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def description(self):
|
|
144
|
+
return self.template.description
|
|
145
|
+
|
|
146
|
+
@description.setter
|
|
147
|
+
def description(self, value: str):
|
|
148
|
+
self.template.description = value
|
|
149
|
+
self._validate_field('description')
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def license(self):
|
|
153
|
+
return self.template.license
|
|
154
|
+
|
|
155
|
+
@license.setter
|
|
156
|
+
def license(self, value: str):
|
|
157
|
+
self.template.license = value
|
|
158
|
+
self._validate_field('license')
|
|
159
|
+
|
|
160
|
+
def build(self) -> Template:
|
|
161
|
+
readme = j2_env.get_template('README.md.j2').render(template=self.template)
|
|
162
|
+
self.template.readme = readme
|
|
163
|
+
self.template.tdk_config.readme_file = consts.DEFAULT_README
|
|
164
|
+
TemplateValidator.validate(self.template)
|
|
165
|
+
|
|
166
|
+
for format_spec in self._formats:
|
|
167
|
+
content = j2_env.get_template('starter.j2').render(template=self.template)
|
|
168
|
+
self.template.files[format_spec.filename] = TemplateFile(
|
|
169
|
+
filename=format_spec.filename,
|
|
170
|
+
content_type='text/plain',
|
|
171
|
+
content=content.encode(encoding=consts.DEFAULT_ENCODING),
|
|
172
|
+
)
|
|
173
|
+
self.template.tdk_config.files = ['src/**/*', '!.git/', '!.env']
|
|
174
|
+
self.template.allowed_packages.append(PackageFilter())
|
|
175
|
+
|
|
176
|
+
license_file = j2_env.get_template('LICENSE.j2').render(template=self.template)
|
|
177
|
+
self.template.tdk_config.files.append('LICENSE')
|
|
178
|
+
self.template.files['LICENSE'] = TemplateFile(
|
|
179
|
+
filename=pathlib.Path('LICENSE'),
|
|
180
|
+
content_type='text/plain',
|
|
181
|
+
content=license_file.encode(encoding=consts.DEFAULT_ENCODING),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
self.template.files['.env'] = TemplateFile(
|
|
185
|
+
filename=pathlib.Path('.env'),
|
|
186
|
+
content_type='text/plain',
|
|
187
|
+
content=create_dot_env().encode(encoding=consts.DEFAULT_ENCODING),
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
return self.template
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def create_dot_env(api_url: str | None = None, api_key: str | None = None) -> str:
|
|
194
|
+
return j2_env.get_template('env.j2').render(api_url=api_url, api_key=api_key)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def safe_utf8(text: str) -> str:
|
|
198
|
+
return text.encode(encoding='utf-8', errors='ignore').decode(encoding='utf-8')
|