plesty-sdk 0.0.2.dev2__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.
- plesty_sdk-0.0.2.dev2.dist-info/METADATA +59 -0
- plesty_sdk-0.0.2.dev2.dist-info/RECORD +20 -0
- plesty_sdk-0.0.2.dev2.dist-info/WHEEL +4 -0
- plesty_sdk-0.0.2.dev2.dist-info/entry_points.txt +2 -0
- plesty_sdk-0.0.2.dev2.dist-info/licenses/COPYING +674 -0
- plesty_sdk-0.0.2.dev2.dist-info/licenses/COPYING.LESSER +165 -0
- plesty_sdk-0.0.2.dev2.dist-info/licenses/LICENSE +165 -0
- plestysdk/__init__.py +1 -0
- plestysdk/assets/docs-build-gitlab-ci.yml +11 -0
- plestysdk/assets/logos/plesty_icon.png +0 -0
- plestysdk/assets/logos/plesty_logo.png +0 -0
- plestysdk/assets/ruff.toml +11 -0
- plestysdk/cache.py +106 -0
- plestysdk/cli.py +32 -0
- plestysdk/commands/check.py +146 -0
- plestysdk/commands/docs/__init__.py +35 -0
- plestysdk/commands/docs/deploy.py +193 -0
- plestysdk/commands/docs/serve.py +80 -0
- plestysdk/commands/docs/sphinx_builder.py +158 -0
- plestysdk/context.py +116 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
plestysdk/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Init."""
|
|
Binary file
|
|
Binary file
|
plestysdk/cache.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Cache management."""
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2025, 2026 Christopher Borchers, fvrehlinger, Maximilian
|
|
4
|
+
# Heller, Michael Zopf (names in alphabetic order wrt. surnames)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of plesty-sdk which is part of the Plesty library.
|
|
7
|
+
#
|
|
8
|
+
# plesty-sdk is free software: you can redistribute it and/or modify it under
|
|
9
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
|
10
|
+
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
11
|
+
# later version.
|
|
12
|
+
#
|
|
13
|
+
# plesty-sdk is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
14
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
15
|
+
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
|
18
|
+
# with plesty-sdk. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
import os
|
|
22
|
+
import shutil
|
|
23
|
+
from collections.abc import Callable
|
|
24
|
+
from importlib import metadata
|
|
25
|
+
from typing import ClassVar
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CachedFile:
|
|
29
|
+
"""Function decorator for defining cached (text) files with content generated at runtime.
|
|
30
|
+
This class also serves as a registry of files to be cached.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
registry: ClassVar[list[CachedFile]] = []
|
|
34
|
+
"""Registry of instanciated CachedFile objects."""
|
|
35
|
+
filename: str
|
|
36
|
+
"""The path to the file to be cached, relative to the '.plesty' cache directory."""
|
|
37
|
+
content: Callable[[], str]
|
|
38
|
+
"""The decorated function that generates the content of the cached file."""
|
|
39
|
+
|
|
40
|
+
def __init__(self, filename: str) -> None:
|
|
41
|
+
"""Add the File object to the registry.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
filename: The path to the file to be cached, relative to the '.plesty'
|
|
45
|
+
cache directory.
|
|
46
|
+
"""
|
|
47
|
+
self.filename = filename
|
|
48
|
+
CachedFile.registry.append(self)
|
|
49
|
+
|
|
50
|
+
def __call__(self, content: Callable[[], str]) -> None:
|
|
51
|
+
"""Apply the decorator to a function."""
|
|
52
|
+
self.content = content
|
|
53
|
+
|
|
54
|
+
def generate(self) -> None:
|
|
55
|
+
"""Write the content of the cached file to disk."""
|
|
56
|
+
complete_file_path = os.path.join(os.getcwd(), '.plesty', self.filename)
|
|
57
|
+
os.makedirs(os.path.dirname(complete_file_path), exist_ok=True)
|
|
58
|
+
with open(complete_file_path, 'xt') as file:
|
|
59
|
+
file.write(self.content())
|
|
60
|
+
|
|
61
|
+
def is_correct(self) -> bool:
|
|
62
|
+
"""Check whether the cached file is up-to-date by comparing the generated content
|
|
63
|
+
with the content of the existing file on disk.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
False, if the file does not exist on disk or its content is not up-to-date.
|
|
67
|
+
True otherwise.
|
|
68
|
+
"""
|
|
69
|
+
complete_file_path = os.path.join(os.getcwd(), '.plesty', self.filename)
|
|
70
|
+
if not os.path.exists(complete_file_path):
|
|
71
|
+
return False
|
|
72
|
+
with open(complete_file_path, 'rt') as file:
|
|
73
|
+
existing_content = file.read()
|
|
74
|
+
if not existing_content == self.content():
|
|
75
|
+
return False
|
|
76
|
+
return True
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def ensure_cache() -> None:
|
|
80
|
+
"""Ensure that the cache directory '.plesty' exists and that all files are
|
|
81
|
+
up-to-date. If not, (re)create the cache.
|
|
82
|
+
"""
|
|
83
|
+
for file in CachedFile.registry:
|
|
84
|
+
if not file.is_correct():
|
|
85
|
+
break
|
|
86
|
+
else:
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
cache_dir_path = os.path.join(os.getcwd(), '.plesty')
|
|
90
|
+
if os.path.exists(cache_dir_path):
|
|
91
|
+
shutil.rmtree(cache_dir_path)
|
|
92
|
+
os.makedirs(cache_dir_path)
|
|
93
|
+
for file in CachedFile.registry:
|
|
94
|
+
file.generate()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@CachedFile('.gitignore')
|
|
98
|
+
def gitignore() -> str:
|
|
99
|
+
"""This file causes the entire '.plesty' cache directory to be ignored by version control."""
|
|
100
|
+
return '*'
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@CachedFile('.sdk-version')
|
|
104
|
+
def sdk_version() -> str:
|
|
105
|
+
"""This file specifies the version number of the Plesty SDK used when creating the cache."""
|
|
106
|
+
return metadata.version('plesty-sdk')
|
plestysdk/cli.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""CLI tool."""
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2025, 2026 Christopher Borchers, fvrehlinger, Maximilian
|
|
4
|
+
# Heller, Michael Zopf (names in alphabetic order wrt. surnames)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of plesty-sdk which is part of the Plesty library.
|
|
7
|
+
#
|
|
8
|
+
# plesty-sdk is free software: you can redistribute it and/or modify it under
|
|
9
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
|
10
|
+
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
11
|
+
# later version.
|
|
12
|
+
#
|
|
13
|
+
# plesty-sdk is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
14
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
15
|
+
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
|
18
|
+
# with plesty-sdk. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
import click
|
|
21
|
+
|
|
22
|
+
from plesty_sdk.commands.check import check_command
|
|
23
|
+
from plesty_sdk.commands.docs import docs_command
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@click.group("plesty")
|
|
27
|
+
def app():
|
|
28
|
+
"""The Plesty CLI tool."""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
app.add_command(check_command)
|
|
32
|
+
app.add_command(docs_command)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Check a module for plesty standard."""
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2025, 2026 Christopher Borchers, fvrehlinger, Maximilian
|
|
4
|
+
# Heller, Michael Zopf (names in alphabetic order wrt. surnames)
|
|
5
|
+
#
|
|
6
|
+
# This file is part of plesty-sdk which is part of the Plesty library.
|
|
7
|
+
#
|
|
8
|
+
# plesty-sdk is free software: you can redistribute it and/or modify it under
|
|
9
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
|
10
|
+
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
11
|
+
# later version.
|
|
12
|
+
#
|
|
13
|
+
# plesty-sdk is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
14
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
15
|
+
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
|
18
|
+
# with plesty-sdk. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
import asyncio
|
|
21
|
+
import importlib
|
|
22
|
+
import subprocess
|
|
23
|
+
from importlib import resources
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
from typing import Any, Literal
|
|
26
|
+
|
|
27
|
+
import click
|
|
28
|
+
from bluesky.protocols import Readable
|
|
29
|
+
try:
|
|
30
|
+
from PySide6.QtWidgets import QWidget
|
|
31
|
+
PYSIDE6_IS_INSTALLED = True
|
|
32
|
+
except ImportError:
|
|
33
|
+
PYSIDE6_IS_INSTALLED = False
|
|
34
|
+
|
|
35
|
+
from plesty_sdk.context import ApplicationContext, pass_context
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@click.command(name="check", short_help="Check compliance with the Plesty standard.")
|
|
39
|
+
@click.option(
|
|
40
|
+
"--standard",
|
|
41
|
+
help="...",
|
|
42
|
+
default="pixel",
|
|
43
|
+
type=click.Choice(["pixel", "nebula", "quantum"]),
|
|
44
|
+
show_choices=True,
|
|
45
|
+
show_default=True,
|
|
46
|
+
)
|
|
47
|
+
@click.option("--device", help="...", is_flag=True)
|
|
48
|
+
@pass_context
|
|
49
|
+
def check_command(
|
|
50
|
+
context: ApplicationContext, standard: Literal["pixel", "nebula", "quantum"], device: bool
|
|
51
|
+
):
|
|
52
|
+
"""..."""
|
|
53
|
+
# ruff
|
|
54
|
+
run_linter()
|
|
55
|
+
|
|
56
|
+
check_gui(standard, context.pyproject_toml)
|
|
57
|
+
|
|
58
|
+
if device:
|
|
59
|
+
check_device(standard, context.pyproject_toml)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def check_gui(standard: Literal["pixel", "nebula", "quantum"], pyproject_toml: dict[str, Any]):
|
|
63
|
+
"""Checks whether the module's GUI class, if present, is compatible with the standard."""
|
|
64
|
+
click.echo("Checking GUI requirements...")
|
|
65
|
+
project_name: str = pyproject_toml["project"]["name"]
|
|
66
|
+
module = importlib.import_module(project_name.replace("-", "_"))
|
|
67
|
+
try:
|
|
68
|
+
gui_class = getattr(module, "GUI")
|
|
69
|
+
except AttributeError:
|
|
70
|
+
click.echo("Module does not implement a GUI.")
|
|
71
|
+
return
|
|
72
|
+
match standard:
|
|
73
|
+
case "pixel":
|
|
74
|
+
click.echo("Check passed, no GUI specific requirements in standard pixel.")
|
|
75
|
+
case "nebula" | "quantum":
|
|
76
|
+
if not PYSIDE6_IS_INSTALLED:
|
|
77
|
+
raise click.ClickException(
|
|
78
|
+
"PySide6 is not installed in the environment, but the GUI "
|
|
79
|
+
"class is required to inherit from PySide6.QtWidgets.QtWidget "
|
|
80
|
+
f"to be compatible with plesty standard {standard}."
|
|
81
|
+
)
|
|
82
|
+
if not issubclass(gui_class, QWidget):
|
|
83
|
+
raise click.ClickException(
|
|
84
|
+
"GUI class does not inherit from PySide6.QtWidgets.QtWidget "
|
|
85
|
+
f"required by plesty standard {standard}."
|
|
86
|
+
)
|
|
87
|
+
try:
|
|
88
|
+
if not callable(getattr(gui_class, "connect")):
|
|
89
|
+
raise AttributeError
|
|
90
|
+
except AttributeError:
|
|
91
|
+
raise click.ClickException(
|
|
92
|
+
"GUI class does not implement a connect method "
|
|
93
|
+
f"required by plesty standard {standard}."
|
|
94
|
+
)
|
|
95
|
+
click.echo(f"Check passed for standard {standard}.")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def check_device(standard: Literal["pixel", "nebula", "quantum"], pyproject_toml: dict[str, Any]):
|
|
99
|
+
"""Checks whether the device has a Bluesky compatible interface."""
|
|
100
|
+
click.echo("Checking device specific requirements...")
|
|
101
|
+
match standard:
|
|
102
|
+
case "pixel":
|
|
103
|
+
click.echo("Check passed, no device specific requirements in standard pixel.")
|
|
104
|
+
case "nebula" | "quantum":
|
|
105
|
+
device_class = pyproject_toml["tool"]["plesty"]["device-class"]
|
|
106
|
+
project_name = pyproject_toml["project"]["name"]
|
|
107
|
+
module = importlib.import_module(project_name.replace("-", "_"))
|
|
108
|
+
device_instance = getattr(module, device_class)()
|
|
109
|
+
# check for compatibility with bluesky Readable
|
|
110
|
+
if not isinstance(device_instance, Readable):
|
|
111
|
+
raise click.ClickException(
|
|
112
|
+
"Device class does not implement the 'Readable' protocol from Bluesky required"
|
|
113
|
+
f"by standard {standard}."
|
|
114
|
+
)
|
|
115
|
+
# check for async connect method
|
|
116
|
+
if not asyncio.iscoroutinefunction(getattr(device_instance, "connect")):
|
|
117
|
+
raise click.ClickException(
|
|
118
|
+
"Device class does not implement an asyncronous 'connect' functions requried"
|
|
119
|
+
f"by plesty standard {standard}."
|
|
120
|
+
)
|
|
121
|
+
click.echo(f"Check passed for standard {standard}.")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def run_linter():
|
|
125
|
+
"""Run ruff linter.
|
|
126
|
+
|
|
127
|
+
Prints errors if checks are not fulfilled and exits.
|
|
128
|
+
Checks pyflakes, pycodestyle errors & warnings and pydocstyle.
|
|
129
|
+
Independent of standard level, as it needs to be fulfilled for every level.
|
|
130
|
+
"""
|
|
131
|
+
pkg_root = resources.files("plesty_sdk")
|
|
132
|
+
config = pkg_root.joinpath("assets/ruff.toml")
|
|
133
|
+
|
|
134
|
+
repo_root = str(Path.cwd())
|
|
135
|
+
with resources.as_file(config) as config_path:
|
|
136
|
+
commands = [
|
|
137
|
+
["ruff", "check", "--config", str(config_path), repo_root],
|
|
138
|
+
["ruff", "format", "--check", "--config", str(config_path), repo_root],
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
for cmd in commands:
|
|
142
|
+
p = subprocess.run(cmd, text=True, capture_output=True)
|
|
143
|
+
print(p.stdout)
|
|
144
|
+
print(p.stderr)
|
|
145
|
+
if p.returncode != 0:
|
|
146
|
+
raise SystemExit(p.returncode)
|