ZedScripts 0.0.2__tar.gz
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.
- zedscripts-0.0.2/LICENSE +21 -0
- zedscripts-0.0.2/PKG-INFO +105 -0
- zedscripts-0.0.2/README.md +86 -0
- zedscripts-0.0.2/pyproject.toml +36 -0
- zedscripts-0.0.2/setup.cfg +4 -0
- zedscripts-0.0.2/src/ZedScripts/__about__.py +1 -0
- zedscripts-0.0.2/src/ZedScripts/__init__.py +38 -0
- zedscripts-0.0.2/src/ZedScripts/enums/Diagnostic.py +165 -0
- zedscripts-0.0.2/src/ZedScripts/enums/SyntaxErrorType.py +7 -0
- zedscripts-0.0.2/src/ZedScripts/environment/__init__.py +33 -0
- zedscripts-0.0.2/src/ZedScripts/environment/config.py +82 -0
- zedscripts-0.0.2/src/ZedScripts/environment/document.py +374 -0
- zedscripts-0.0.2/src/ZedScripts/environment/mod.py +62 -0
- zedscripts-0.0.2/src/ZedScripts/environment/version.py +202 -0
- zedscripts-0.0.2/src/ZedScripts/environment/workspace.py +320 -0
- zedscripts-0.0.2/src/ZedScripts/locale/en.json +38 -0
- zedscripts-0.0.2/src/ZedScripts/main.py +7 -0
- zedscripts-0.0.2/src/ZedScripts/providers/actions.py +13 -0
- zedscripts-0.0.2/src/ZedScripts/providers/capabilities.py +107 -0
- zedscripts-0.0.2/src/ZedScripts/providers/configuration.py +26 -0
- zedscripts-0.0.2/src/ZedScripts/providers/debug.py +59 -0
- zedscripts-0.0.2/src/ZedScripts/providers/diagnostics.py +101 -0
- zedscripts-0.0.2/src/ZedScripts/providers/hover.py +37 -0
- zedscripts-0.0.2/src/ZedScripts/providers/http.py +49 -0
- zedscripts-0.0.2/src/ZedScripts/providers/locale.py +80 -0
- zedscripts-0.0.2/src/ZedScripts/providers/notifications.py +45 -0
- zedscripts-0.0.2/src/ZedScripts/providers/semantic_tokens.py +189 -0
- zedscripts-0.0.2/src/ZedScripts/scripts/__init__.py +160 -0
- zedscripts-0.0.2/src/ZedScripts/scripts/block.py +547 -0
- zedscripts-0.0.2/src/ZedScripts/scripts/dataset.py +355 -0
- zedscripts-0.0.2/src/ZedScripts/scripts/value.py +706 -0
- zedscripts-0.0.2/src/ZedScripts/scripts/version.py +75 -0
- zedscripts-0.0.2/src/ZedScripts/server.py +288 -0
- zedscripts-0.0.2/src/ZedScripts/structure/ast.py +143 -0
- zedscripts-0.0.2/src/ZedScripts/structure/lexer.py +482 -0
- zedscripts-0.0.2/src/ZedScripts/structure/parser.py +243 -0
- zedscripts-0.0.2/src/ZedScripts/utils.py +85 -0
- zedscripts-0.0.2/src/ZedScripts.egg-info/PKG-INFO +105 -0
- zedscripts-0.0.2/src/ZedScripts.egg-info/SOURCES.txt +40 -0
- zedscripts-0.0.2/src/ZedScripts.egg-info/dependency_links.txt +1 -0
- zedscripts-0.0.2/src/ZedScripts.egg-info/requires.txt +11 -0
- zedscripts-0.0.2/src/ZedScripts.egg-info/top_level.txt +1 -0
zedscripts-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PZ Wiki Modding
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ZedScripts
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Author: SimKDT
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.12.3
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: lsprotocol
|
|
10
|
+
Requires-Dist: pygls
|
|
11
|
+
Requires-Dist: requests-cache
|
|
12
|
+
Requires-Dist: pydantic
|
|
13
|
+
Requires-Dist: deepmerge
|
|
14
|
+
Provides-Extra: build
|
|
15
|
+
Requires-Dist: pyinstaller; extra == "build"
|
|
16
|
+
Provides-Extra: debug
|
|
17
|
+
Requires-Dist: debugpy; extra == "debug"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# ZedScripts LSP
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
[](LICENSE)
|
|
24
|
+

|
|
25
|
+
[](https://pypi.org/project/ZedScripts-LSP/)
|
|
26
|
+
[](https://pypi.org/project/ZedScripts-LSP/)
|
|
27
|
+
|
|
28
|
+
> [!IMPORTANT]
|
|
29
|
+
> Work In Progress, this is a BETA release
|
|
30
|
+
|
|
31
|
+
ZedScripts LSP is a language server protocol implementation in Python for the [scripting format]() of Project Zomboid. Previously a VSCode extension, it is now reimplemented as a standalone LSP.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
### Releases
|
|
35
|
+
|
|
36
|
+
### Python package
|
|
37
|
+
|
|
38
|
+
<!-- <details open>
|
|
39
|
+
<summary>PyPi</summary>
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install ZedScripts-LSP
|
|
43
|
+
```
|
|
44
|
+
</details> -->
|
|
45
|
+
|
|
46
|
+
<details>
|
|
47
|
+
<summary>Git</summary>
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install git+https://github.com/PZ-Wiki-Modding/ZedScripts-LSP.git
|
|
51
|
+
```
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Local</summary>
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install .
|
|
59
|
+
```
|
|
60
|
+
</details>
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
You can either launch the LSP from Python or you can launch the software as is.
|
|
65
|
+
|
|
66
|
+
### LSP cache directory
|
|
67
|
+
|
|
68
|
+
The LSP uses a cache directory on your system to store temporary files and logs as well as configuration files. You can find it here:
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Linux</summary>
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
~/.zedscripts
|
|
75
|
+
```
|
|
76
|
+
</details>
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary>Windows</summary>
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
%USERPROFILE%\.zedscripts
|
|
83
|
+
```
|
|
84
|
+
</details>
|
|
85
|
+
|
|
86
|
+
### Configuration
|
|
87
|
+
|
|
88
|
+
The LSP uses configurations files which provide information to the LSP about various settings. You have access to a global configuration file
|
|
89
|
+
|
|
90
|
+
Example configuration:
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"dataset": {
|
|
94
|
+
"latest": true
|
|
95
|
+
},
|
|
96
|
+
"libraries": [
|
|
97
|
+
"/home/simon/.steam/debian-installation/steamapps/common/ProjectZomboid/projectzomboid/media",
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
WIP: proper documentation will come soon
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# ZedScripts LSP
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](LICENSE)
|
|
5
|
+

|
|
6
|
+
[](https://pypi.org/project/ZedScripts-LSP/)
|
|
7
|
+
[](https://pypi.org/project/ZedScripts-LSP/)
|
|
8
|
+
|
|
9
|
+
> [!IMPORTANT]
|
|
10
|
+
> Work In Progress, this is a BETA release
|
|
11
|
+
|
|
12
|
+
ZedScripts LSP is a language server protocol implementation in Python for the [scripting format]() of Project Zomboid. Previously a VSCode extension, it is now reimplemented as a standalone LSP.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
### Releases
|
|
16
|
+
|
|
17
|
+
### Python package
|
|
18
|
+
|
|
19
|
+
<!-- <details open>
|
|
20
|
+
<summary>PyPi</summary>
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install ZedScripts-LSP
|
|
24
|
+
```
|
|
25
|
+
</details> -->
|
|
26
|
+
|
|
27
|
+
<details>
|
|
28
|
+
<summary>Git</summary>
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install git+https://github.com/PZ-Wiki-Modding/ZedScripts-LSP.git
|
|
32
|
+
```
|
|
33
|
+
</details>
|
|
34
|
+
|
|
35
|
+
<details>
|
|
36
|
+
<summary>Local</summary>
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install .
|
|
40
|
+
```
|
|
41
|
+
</details>
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
You can either launch the LSP from Python or you can launch the software as is.
|
|
46
|
+
|
|
47
|
+
### LSP cache directory
|
|
48
|
+
|
|
49
|
+
The LSP uses a cache directory on your system to store temporary files and logs as well as configuration files. You can find it here:
|
|
50
|
+
|
|
51
|
+
<details>
|
|
52
|
+
<summary>Linux</summary>
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
~/.zedscripts
|
|
56
|
+
```
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
<details>
|
|
60
|
+
<summary>Windows</summary>
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
%USERPROFILE%\.zedscripts
|
|
64
|
+
```
|
|
65
|
+
</details>
|
|
66
|
+
|
|
67
|
+
### Configuration
|
|
68
|
+
|
|
69
|
+
The LSP uses configurations files which provide information to the LSP about various settings. You have access to a global configuration file
|
|
70
|
+
|
|
71
|
+
Example configuration:
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"dataset": {
|
|
75
|
+
"latest": true
|
|
76
|
+
},
|
|
77
|
+
"libraries": [
|
|
78
|
+
"/home/simon/.steam/debian-installation/steamapps/common/ProjectZomboid/projectzomboid/media",
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
WIP: proper documentation will come soon
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ZedScripts"
|
|
3
|
+
description = ""
|
|
4
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
5
|
+
requires-python = ">=3.12.3"
|
|
6
|
+
version = "0.0.2"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "SimKDT" },
|
|
11
|
+
]
|
|
12
|
+
dependencies = [
|
|
13
|
+
"lsprotocol",
|
|
14
|
+
"pygls",
|
|
15
|
+
"requests-cache",
|
|
16
|
+
"pydantic",
|
|
17
|
+
"deepmerge",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
build = [
|
|
22
|
+
"pyinstaller"
|
|
23
|
+
]
|
|
24
|
+
debug = [
|
|
25
|
+
"debugpy"
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
# used to load locale JSON files
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["setuptools>=61"]
|
|
31
|
+
build-backend = "setuptools.build_meta"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools.package-data]
|
|
34
|
+
ZedScripts = [
|
|
35
|
+
"locale/*.json"
|
|
36
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
IS_DEBUG = os.getenv("ZEDSCRIPTS_DEBUG_MODE") == "1"
|
|
6
|
+
|
|
7
|
+
ZEDSCRIPT_CACHE_DIR = Path.home() / ".zedscripts"
|
|
8
|
+
"""
|
|
9
|
+
Cache directory to hold various information related to ZedScripts.
|
|
10
|
+
"""
|
|
11
|
+
ZEDSCRIPT_CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
|
12
|
+
|
|
13
|
+
# config files
|
|
14
|
+
CONFIGURATION_FILE_NAME = ".zedscripts.json"
|
|
15
|
+
GLOBAL_CONFIGURATION_FILE = (ZEDSCRIPT_CACHE_DIR / CONFIGURATION_FILE_NAME).resolve()
|
|
16
|
+
|
|
17
|
+
# setup the logger
|
|
18
|
+
log_file = ZEDSCRIPT_CACHE_DIR / "server.log"
|
|
19
|
+
|
|
20
|
+
level = logging.DEBUG if IS_DEBUG else logging.INFO
|
|
21
|
+
logging.basicConfig(
|
|
22
|
+
filename=log_file,
|
|
23
|
+
level=level,
|
|
24
|
+
format="%(asctime)s %(levelname)s %(message)s",
|
|
25
|
+
filemode="w",
|
|
26
|
+
# force=True,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
logging.info("ZedScripts logger initialized. Debug mode: %s", IS_DEBUG)
|
|
30
|
+
|
|
31
|
+
IDENTIFIER = "ZedScripts"
|
|
32
|
+
SOURCE = IDENTIFIER
|
|
33
|
+
|
|
34
|
+
SCRIPTS_DATA_MANIFEST = "https://raw.githubusercontent.com/PZ-Wiki-Modding/pz-scripts-data/refs/heads/main/manifest.json"
|
|
35
|
+
SCRIPTS_BLOCKS_DATA_LINK = "https://raw.githubusercontent.com/PZ-Wiki-Modding/pz-scripts-data/refs/tags/{best_tag}/out/scriptsBlocks.json"
|
|
36
|
+
ROOTS_DATA_LINK = "https://raw.githubusercontent.com/PZ-Wiki-Modding/pz-scripts-data/refs/tags/{best_tag}/out/roots.json"
|
|
37
|
+
|
|
38
|
+
SCRIPTSDOCS_LINK = "https://pz-wiki-modding.github.io/PZ-API-Docs/scripts/"
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from lsprotocol.types import DiagnosticSeverity, DiagnosticTag
|
|
5
|
+
|
|
6
|
+
from ..enums.SyntaxErrorType import SyntaxErrorType
|
|
7
|
+
from ..providers.diagnostics import DiagnosticDefinition
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DiagnosticType(enum.Enum):
|
|
11
|
+
@classmethod
|
|
12
|
+
def _missing_(cls, value: Any) -> 'DiagnosticType | None':
|
|
13
|
+
if isinstance(value, SyntaxErrorType):
|
|
14
|
+
return cls["PARSER_" + value.name]
|
|
15
|
+
return None
|
|
16
|
+
|
|
17
|
+
# syntax diagnostics
|
|
18
|
+
PARSER_TOO_MANY_CLOSING_BRACKETS = enum.auto()
|
|
19
|
+
PARSER_BLOCK_MISSING_TYPE = enum.auto()
|
|
20
|
+
PARSER_BLOCK_NOT_CLOSED = enum.auto()
|
|
21
|
+
PARSER_UNPARSED_TOKENS = enum.auto()
|
|
22
|
+
|
|
23
|
+
# block diagnostics
|
|
24
|
+
BLOCK_UNKNOWN_BLOCK = enum.auto()
|
|
25
|
+
|
|
26
|
+
# ID related diagnostics
|
|
27
|
+
BLOCK_UNEXPECTED_ID = enum.auto()
|
|
28
|
+
BLOCK_MISSING_ID = enum.auto()
|
|
29
|
+
BLOCK_HAS_ID_IN_PARENT = enum.auto()
|
|
30
|
+
BLOCK_ID_CANNOT_CONTAIN_SPACES = enum.auto()
|
|
31
|
+
BLOCK_INVALID_ID = enum.auto()
|
|
32
|
+
BLOCK_FORBIDDEN_ID = enum.auto()
|
|
33
|
+
|
|
34
|
+
# parameters diagnostics
|
|
35
|
+
VALUE_UNKNOWN_PARAMETER = enum.auto()
|
|
36
|
+
VALUE_DEPRECATED_REPLACEMENT_VERSION = enum.auto()
|
|
37
|
+
VALUE_DEPRECATED_REPLACEMENT = enum.auto()
|
|
38
|
+
VALUE_DEPRECATED_VERSION = enum.auto()
|
|
39
|
+
VALUE_DEPRECATED = enum.auto()
|
|
40
|
+
VALUE_DUPLICATE = enum.auto()
|
|
41
|
+
VALUE_MISSING = enum.auto()
|
|
42
|
+
VALUE_FORBIDDEN = enum.auto()
|
|
43
|
+
VALUE_INVALID_TYPE = enum.auto()
|
|
44
|
+
VALUE_INVALID_OBJECT_FORMAT = enum.auto()
|
|
45
|
+
VALUE_INVALID_OBJECT_KEY_TYPE = enum.auto()
|
|
46
|
+
VALUE_INVALID_OBJECT_VALUE_TYPE = enum.auto()
|
|
47
|
+
VALUE_WRONGLY_FORMATTED_KEY_VALUE_PAIR = enum.auto()
|
|
48
|
+
VALUE_WITH_NEWLINE = enum.auto()
|
|
49
|
+
VALUE_INVALID_BLOCK_REFERENCE = enum.auto()
|
|
50
|
+
VALUE_CANNOT_PROVIDE_MODULE = enum.auto()
|
|
51
|
+
VALUE_BLOCK_REF_CANNOT_BE_EMPTY = enum.auto()
|
|
52
|
+
VALUE_UNMATCHED_BLOCK_REF = enum.auto()
|
|
53
|
+
VALUE_MULTIPLE_BLOCK_REFS = enum.auto()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# syntax diagnostics
|
|
57
|
+
DiagnosticDefinition(DiagnosticType.PARSER_TOO_MANY_CLOSING_BRACKETS,
|
|
58
|
+
DiagnosticSeverity.Error)
|
|
59
|
+
DiagnosticDefinition(DiagnosticType.PARSER_BLOCK_MISSING_TYPE,
|
|
60
|
+
DiagnosticSeverity.Error)
|
|
61
|
+
DiagnosticDefinition(DiagnosticType.PARSER_BLOCK_NOT_CLOSED,
|
|
62
|
+
DiagnosticSeverity.Warning)
|
|
63
|
+
DiagnosticDefinition(DiagnosticType.PARSER_UNPARSED_TOKENS,
|
|
64
|
+
DiagnosticSeverity.Error)
|
|
65
|
+
|
|
66
|
+
# block diagnostics
|
|
67
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_UNKNOWN_BLOCK,
|
|
68
|
+
DiagnosticSeverity.Error,
|
|
69
|
+
args={"type": str},
|
|
70
|
+
tags=[DiagnosticTag.Unnecessary])
|
|
71
|
+
|
|
72
|
+
# ID related diagnostics
|
|
73
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_UNEXPECTED_ID,
|
|
74
|
+
DiagnosticSeverity.Error,
|
|
75
|
+
args={"type": str, "id": str},
|
|
76
|
+
tags=[DiagnosticTag.Unnecessary])
|
|
77
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_MISSING_ID,
|
|
78
|
+
DiagnosticSeverity.Error,
|
|
79
|
+
args={"type": str, "id": str})
|
|
80
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_HAS_ID_IN_PARENT,
|
|
81
|
+
DiagnosticSeverity.Error,
|
|
82
|
+
args={"type": str, "parent_type": str, "invalid_blocks": list},
|
|
83
|
+
tags=[DiagnosticTag.Unnecessary])
|
|
84
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_ID_CANNOT_CONTAIN_SPACES,
|
|
85
|
+
DiagnosticSeverity.Error,
|
|
86
|
+
args={"type": str, "id": str})
|
|
87
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_INVALID_ID,
|
|
88
|
+
DiagnosticSeverity.Error,
|
|
89
|
+
args={"type": str, "id": str, "validIDs": list})
|
|
90
|
+
DiagnosticDefinition(DiagnosticType.BLOCK_FORBIDDEN_ID,
|
|
91
|
+
DiagnosticSeverity.Error,
|
|
92
|
+
args={"type": str, "id": str, "forbiddenIDs": list})
|
|
93
|
+
|
|
94
|
+
# parameter diagnostics
|
|
95
|
+
DiagnosticDefinition(DiagnosticType.VALUE_UNKNOWN_PARAMETER,
|
|
96
|
+
DiagnosticSeverity.Hint,
|
|
97
|
+
args={"type": str, "key": str},
|
|
98
|
+
tags=[DiagnosticTag.Unnecessary])
|
|
99
|
+
DiagnosticDefinition(DiagnosticType.VALUE_DEPRECATED_REPLACEMENT_VERSION,
|
|
100
|
+
DiagnosticSeverity.Warning,
|
|
101
|
+
args={"description": str, "replacement": str, "version": str},
|
|
102
|
+
tags=[DiagnosticTag.Deprecated])
|
|
103
|
+
DiagnosticDefinition(DiagnosticType.VALUE_DEPRECATED_REPLACEMENT,
|
|
104
|
+
DiagnosticSeverity.Warning,
|
|
105
|
+
args={"description": str, "replacement": str},
|
|
106
|
+
tags=[DiagnosticTag.Deprecated])
|
|
107
|
+
DiagnosticDefinition(DiagnosticType.VALUE_DEPRECATED_VERSION,
|
|
108
|
+
DiagnosticSeverity.Warning,
|
|
109
|
+
args={"description": str, "version": str},
|
|
110
|
+
tags=[DiagnosticTag.Deprecated])
|
|
111
|
+
DiagnosticDefinition(DiagnosticType.VALUE_DEPRECATED,
|
|
112
|
+
DiagnosticSeverity.Warning,
|
|
113
|
+
args={"description": str},
|
|
114
|
+
tags=[DiagnosticTag.Deprecated])
|
|
115
|
+
DiagnosticDefinition(DiagnosticType.VALUE_DUPLICATE,
|
|
116
|
+
DiagnosticSeverity.Warning,
|
|
117
|
+
args={"type": str, "key": str})
|
|
118
|
+
DiagnosticDefinition(DiagnosticType.VALUE_MISSING,
|
|
119
|
+
DiagnosticSeverity.Warning,
|
|
120
|
+
args={"type": str, "key": str})
|
|
121
|
+
DiagnosticDefinition(DiagnosticType.VALUE_FORBIDDEN,
|
|
122
|
+
DiagnosticSeverity.Warning,
|
|
123
|
+
args={"type": str, "key": str, "forbidden_values": list, "accepted_values": list})
|
|
124
|
+
DiagnosticDefinition(DiagnosticType.VALUE_INVALID_TYPE,
|
|
125
|
+
DiagnosticSeverity.Error,
|
|
126
|
+
args={"key": str, "value": str, "expected_type": str, "actual_type": str})
|
|
127
|
+
DiagnosticDefinition(DiagnosticType.VALUE_INVALID_OBJECT_FORMAT,
|
|
128
|
+
DiagnosticSeverity.Error,
|
|
129
|
+
args={"type": str, "key": str, "key_value_separator": str})
|
|
130
|
+
DiagnosticDefinition(DiagnosticType.VALUE_INVALID_OBJECT_KEY_TYPE,
|
|
131
|
+
DiagnosticSeverity.Error,
|
|
132
|
+
args={"obj_key": str, "key": str, "expected_type": str, "actual_type": str})
|
|
133
|
+
DiagnosticDefinition(DiagnosticType.VALUE_INVALID_OBJECT_VALUE_TYPE,
|
|
134
|
+
DiagnosticSeverity.Error,
|
|
135
|
+
args={"obj_value": str, "key": str, "expected_type": str, "actual_type": str})
|
|
136
|
+
DiagnosticDefinition(DiagnosticType.VALUE_WRONGLY_FORMATTED_KEY_VALUE_PAIR,
|
|
137
|
+
DiagnosticSeverity.Warning,
|
|
138
|
+
args={"type": str, "key": str, "value": str})
|
|
139
|
+
DiagnosticDefinition(DiagnosticType.VALUE_WITH_NEWLINE,
|
|
140
|
+
DiagnosticSeverity.Information,
|
|
141
|
+
args={"type": str, "key": str, "value": str})
|
|
142
|
+
DiagnosticDefinition(DiagnosticType.VALUE_INVALID_BLOCK_REFERENCE,
|
|
143
|
+
DiagnosticSeverity.Error,
|
|
144
|
+
args={"value": str})
|
|
145
|
+
DiagnosticDefinition(DiagnosticType.VALUE_CANNOT_PROVIDE_MODULE,
|
|
146
|
+
DiagnosticSeverity.Error,
|
|
147
|
+
args={"value": str, "module": str})
|
|
148
|
+
DiagnosticDefinition(DiagnosticType.VALUE_BLOCK_REF_CANNOT_BE_EMPTY,
|
|
149
|
+
DiagnosticSeverity.Error,
|
|
150
|
+
args={"value": str})
|
|
151
|
+
DiagnosticDefinition(DiagnosticType.VALUE_UNMATCHED_BLOCK_REF,
|
|
152
|
+
DiagnosticSeverity.Error,
|
|
153
|
+
args={"value": str, "parameter": str, "expected_block": str})
|
|
154
|
+
DiagnosticDefinition(DiagnosticType.VALUE_MULTIPLE_BLOCK_REFS,
|
|
155
|
+
DiagnosticSeverity.Error,
|
|
156
|
+
args={"value": str, "parameter": str, "expected_block": str})
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# ensure that all diagnostic types have a corresponding definition
|
|
160
|
+
for diagnostic_type in DiagnosticType:
|
|
161
|
+
assert diagnostic_type in DiagnosticDefinition.by_type, f"Missing definition for diagnostic type: {diagnostic_type}"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class WorkspaceType(enum.StrEnum):
|
|
5
|
+
"""Represents different types of workspace folders."""
|
|
6
|
+
LIBRARY = enum.auto()
|
|
7
|
+
"""A library defined by the user to reference things from.
|
|
8
|
+
No validation should be performed on it."""
|
|
9
|
+
PROJECT = enum.auto()
|
|
10
|
+
"""A workspace folder."""
|
|
11
|
+
SOLITARY = enum.auto()
|
|
12
|
+
"""Files that are not opened as part of a workspace
|
|
13
|
+
or library but should still be validated.
|
|
14
|
+
|
|
15
|
+
This workspace always exists and just holds solitary files."""
|
|
16
|
+
|
|
17
|
+
class VersionType(enum.StrEnum):
|
|
18
|
+
"""Represents different version types the workspace folders follow."""
|
|
19
|
+
PRE_42 = enum.auto()
|
|
20
|
+
"""Modded pre-42 folder structure."""
|
|
21
|
+
VERSIONING = enum.auto()
|
|
22
|
+
"""Modded versioning folder.
|
|
23
|
+
|
|
24
|
+
https://pzwiki.net/wiki/Mod_structure#Common_and_versioning_folders"""
|
|
25
|
+
COMMON = enum.auto()
|
|
26
|
+
"""Modded folder `common`.
|
|
27
|
+
|
|
28
|
+
https://pzwiki.net/wiki/Mod_structure#Common_and_versioning_folders"""
|
|
29
|
+
OTHER = enum.auto()
|
|
30
|
+
"""Other uncategorized version."""
|
|
31
|
+
BASE_GAME = enum.auto()
|
|
32
|
+
"""Base game files (e.g., `ProjectZomboid/media`)."""
|
|
33
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import enum
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
from ..scripts.version import DataVersion
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DatasetTag(enum.Enum):
|
|
11
|
+
LATEST = "latest"
|
|
12
|
+
STABLE = "stable"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ReleaseModel(BaseModel):
|
|
17
|
+
major: int = Field(
|
|
18
|
+
description="Build game version number.",
|
|
19
|
+
ge=42,
|
|
20
|
+
)
|
|
21
|
+
minor: int = Field(
|
|
22
|
+
description="Minor game version number.",
|
|
23
|
+
ge=0,
|
|
24
|
+
)
|
|
25
|
+
patch: int = Field(
|
|
26
|
+
description="Patch game version number.",
|
|
27
|
+
ge=0,
|
|
28
|
+
)
|
|
29
|
+
version: Optional[int] = Field(
|
|
30
|
+
description="Dataset version number for the provided Build release (major.minor.patch). This is incremented whenever the dataset for a specific version is updated.",
|
|
31
|
+
default=None,
|
|
32
|
+
ge=0,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
class DatasetModel(BaseModel):
|
|
36
|
+
release: Optional[ReleaseModel] = Field(
|
|
37
|
+
description="Provides a configuration for the dataset version to use for validation. This overrides the `latest` and `stable` fields if set.",
|
|
38
|
+
default=None,
|
|
39
|
+
)
|
|
40
|
+
latest: Optional[bool] = Field(
|
|
41
|
+
description="Indicates whether to use the latest dataset version for validation. This is ignored if `release` is set. Overrides the `stable` field if set.",
|
|
42
|
+
default=False,
|
|
43
|
+
)
|
|
44
|
+
stable: Optional[bool] = Field(
|
|
45
|
+
description="Provides a configuration for the stable dataset version to use for validation. Ignored if `release` or `latest` is set.",
|
|
46
|
+
default=True,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def to_data_version(self) -> DataVersion | DatasetTag:
|
|
50
|
+
if self.release is None:
|
|
51
|
+
if self.latest:
|
|
52
|
+
return DatasetTag.LATEST
|
|
53
|
+
if self.stable:
|
|
54
|
+
return DatasetTag.STABLE
|
|
55
|
+
logging.warning("No dataset version specified, defaulting to 'stable'.")
|
|
56
|
+
return DatasetTag.STABLE
|
|
57
|
+
from ..scripts.dataset import Manifest
|
|
58
|
+
try:
|
|
59
|
+
return Manifest.from_release_model(self.release)
|
|
60
|
+
except Exception as e:
|
|
61
|
+
logging.error(f"Failed to get data version from release model: {e}. Defaulting to 'stable'.")
|
|
62
|
+
return DatasetTag.STABLE
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ConfigurationModel(BaseModel):
|
|
66
|
+
"""Represents the content of the configuration files for workspace environments."""
|
|
67
|
+
dataset: DatasetModel = Field(
|
|
68
|
+
description="Provides configuration for the dataset version to use for diagnostics.",
|
|
69
|
+
default_factory=DatasetModel,
|
|
70
|
+
)
|
|
71
|
+
libraries: set[Path] = Field(
|
|
72
|
+
description="Set of library folders to reference. Usually this should contain the base game folder.",
|
|
73
|
+
default_factory=set,
|
|
74
|
+
)
|
|
75
|
+
ignored: set[str] = Field(
|
|
76
|
+
description="Regex patterns for files and folders to ignore in the workspace.",
|
|
77
|
+
default=set([
|
|
78
|
+
r"tileGeometry\.txt",
|
|
79
|
+
r"tileDepthTextureAssignments\.txt",
|
|
80
|
+
r".+\.tiles\.txt"
|
|
81
|
+
]),
|
|
82
|
+
)
|