pz-scripts-data 1.1.2__tar.gz → 1.2.0__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.
Files changed (19) hide show
  1. {pz_scripts_data-1.1.2/src/pz_scripts_data.egg-info → pz_scripts_data-1.2.0}/PKG-INFO +1 -1
  2. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/pyproject.toml +1 -1
  3. pz_scripts_data-1.2.0/src/pz_scripts_data/blocks.py +65 -0
  4. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/schema.py +45 -16
  5. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0/src/pz_scripts_data.egg-info}/PKG-INFO +1 -1
  6. pz_scripts_data-1.1.2/src/pz_scripts_data/blocks.py +0 -6
  7. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/LICENSE +0 -0
  8. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/README.md +0 -0
  9. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/setup.cfg +0 -0
  10. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/formatBlocks.py +0 -0
  11. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/py.typed +0 -0
  12. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/release.py +0 -0
  13. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/sortItemParameters.py +0 -0
  14. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data/validateBlocks.py +0 -0
  15. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data.egg-info/SOURCES.txt +0 -0
  16. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data.egg-info/dependency_links.txt +0 -0
  17. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data.egg-info/entry_points.txt +0 -0
  18. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data.egg-info/requires.txt +0 -0
  19. {pz_scripts_data-1.1.2 → pz_scripts_data-1.2.0}/src/pz_scripts_data.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pz-scripts-data
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Dataset for the Scripts of Project Zomboid.
5
5
  Author: SimKDT
6
6
  License-Expression: MIT
@@ -3,7 +3,7 @@ name = "pz-scripts-data"
3
3
  description = "Dataset for the Scripts of Project Zomboid."
4
4
  readme = { file = "README.md", content-type = "text/markdown" }
5
5
  requires-python = ">=3.12.3"
6
- version = "1.1.2"
6
+ version = "1.2.0"
7
7
  license = "MIT"
8
8
  authors = [
9
9
  { name = "SimKDT" },
@@ -0,0 +1,65 @@
1
+ from enum import StrEnum
2
+
3
+ class BlockProperties(StrEnum):
4
+ VERSION = 'version'
5
+ REF_DESC = '#desc'
6
+ REF_FULL = '#ref'
7
+ DEPRECATED = 'deprecated'
8
+
9
+ NAME = 'name'
10
+ ID = 'ID'
11
+ SOFT_OVERRIDE = 'softOverride'
12
+ NO_COMMA = 'noComma'
13
+ PATTERN = 'pattern'
14
+
15
+ DESCRIPTION = 'description'
16
+ SHORT_DESCRIPTION = 'short_description'
17
+
18
+ VARIANT = 'variantOf'
19
+ VARIANTS = 'variants'
20
+
21
+ PARENTS = 'parents'
22
+ CHILDREN = 'children'
23
+ NEEDS_CHILDREN = 'needsChildren'
24
+ PARAMETERS = 'parameters'
25
+ PROPERTIES = 'properties'
26
+
27
+ IS_ROOT = 'isRoot'
28
+
29
+ class IDProperties(StrEnum):
30
+ OPTIONAL = 'optional'
31
+ CAN_HAVE_SPACES = 'canHaveSpace'
32
+ FORBIDDEN = 'forbidden'
33
+
34
+ VALUES = 'values'
35
+ PARENTS_WITHOUT = 'parentsWithout'
36
+ AS_TYPE = 'asType'
37
+
38
+ TRANSLATION = 'translation'
39
+
40
+ class ParameterProperties(StrEnum):
41
+ REF_DESC = '#desc'
42
+ REF_FULL = '#ref'
43
+
44
+ NAME = 'name'
45
+ DESCRIPTION = 'description'
46
+
47
+ TYPE = 'type'
48
+ DEFAULT = 'default'
49
+ REQUIRED = 'required'
50
+ CAN_BE_EMPTY = 'canBeEmpty'
51
+ MINIMUM = 'minimum'
52
+ MAXIMUM = 'maximum'
53
+ VALUES = 'values'
54
+
55
+ DEPRECATED = 'deprecated'
56
+ IS_USELESS = 'isUseless'
57
+ ALLOW_DUPLICATES = 'allowDuplicates'
58
+ INCOMPATIBLE_WITH = 'incompatibleWith'
59
+
60
+ SEE_ALSO = 'seeAlso'
61
+
62
+ class PropertyData(StrEnum):
63
+ NAME = 'name'
64
+ DESCRIPTION = 'description'
65
+ PROPERTIES = 'properties'
@@ -7,7 +7,7 @@
7
7
  import json
8
8
  import sys
9
9
  from pathlib import Path
10
- from typing import Annotated, Any, Literal, Self
10
+ from typing import Annotated, Any, Literal, Self, TypeVar, Generic
11
11
 
12
12
  from pydantic import BaseModel, ConfigDict, Field, WithJsonSchema, model_validator
13
13
  from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
@@ -15,7 +15,30 @@ from pydantic_core import core_schema
15
15
 
16
16
  DEFAULT_OUTPUT = Path(__file__).resolve().parents[2] / "schemas" / "blocks.json"
17
17
 
18
- ScalarType = Literal["string", "float", "boolean", "integer"]
18
+ StringType = Literal["string"]
19
+ FloatType = Literal["float"]
20
+ BooleanType = Literal["boolean"]
21
+ IntegerType = Literal["integer"]
22
+ ScalarType = (
23
+ StringType
24
+ | FloatType
25
+ | BooleanType
26
+ | IntegerType
27
+ )
28
+ TranslationType = Literal["translation"]
29
+ CallBackType = Literal["callback"]
30
+ BlockType = Literal["block"]
31
+ ObjectType = Literal["object"]
32
+ ArrayType = Literal["array"]
33
+ ParameterMainType = (
34
+ ScalarType
35
+ | TranslationType
36
+ | CallBackType
37
+ | BlockType
38
+ | ObjectType
39
+ | ArrayType
40
+ )
41
+
19
42
 
20
43
  # Accepts whole numbers as int so they are not widened to float on output. The JSON Schema stays "number".
21
44
  Number = Annotated[int | float, WithJsonSchema({"type": "number"})]
@@ -206,45 +229,51 @@ class CallbackDefinition(SchemaModel):
206
229
  returns: str | None = Field(None, description="The return type of the callback function.")
207
230
 
208
231
 
209
- class ArrayParameterType(SchemaModel):
210
- main: Literal["array"] = Field(description="The main data type of the parameter.")
232
+ T = TypeVar('T')
233
+ class ParameterType(SchemaModel, Generic[T]):
234
+ """Represents the type of a parameter."""
235
+ main: T = Field(description="The main data type of the parameter.")
236
+
237
+
238
+ class ArrayParameterType(ParameterType[ArrayType]):
239
+ main: ArrayType = Field(description="The main data type of the parameter.")
211
240
  array: ArrayDefinition = Field(
212
241
  description="If the parameter is of type 'array', this can be used to provide a description of the expected format of the array.",
213
242
  )
214
243
 
215
244
 
216
- class ObjectParameterType(SchemaModel):
217
- main: Literal["object"] = Field(description="The main data type of the parameter.")
218
- object_: ObjectDefinition = Field(
245
+ class ObjectParameterType(ParameterType[ObjectType]):
246
+ main: ObjectType = Field(description="The main data type of the parameter.")
247
+ object: ObjectDefinition = Field(
219
248
  alias="object",
220
249
  description="If the parameter is of type 'object', this can be used to provide a description of the expected format of the object.",
221
250
  )
222
251
 
223
252
 
224
- class BlockParameterType(SchemaModel):
225
- main: Literal["block"] = Field(description="The main data type of the parameter.")
253
+ class BlockParameterType(ParameterType[BlockType]):
254
+ main: BlockType = Field(description="The main data type of the parameter.")
226
255
  block: BlockReference = Field(
227
256
  description="If the parameter is of type 'block', this can be used to provide a description of the expected format of the block.",
228
257
  )
229
258
 
230
259
 
231
- class CallbackParameterType(SchemaModel):
232
- main: Literal["callback"] = Field(description="The main data type of the parameter.")
260
+ class CallbackParameterType(ParameterType[CallBackType]):
261
+ main: CallBackType = Field(description="The main data type of the parameter.")
233
262
  callback: CallbackDefinition = Field(description="Indicates whether the parameter is a callback function.")
234
263
 
235
264
 
236
- class TranslationParameterType(SchemaModel):
237
- main: Literal["translation"] = Field(description="The main data type of the parameter.")
265
+ class TranslationParameterType(ParameterType[TranslationType]):
266
+ main: TranslationType = Field(description="The main data type of the parameter.")
238
267
  translation: TranslationDefinition = Field(
239
268
  description="If the parameter is of type 'translation', this can be used to provide a description of the expected format of the translation.",
240
269
  )
241
270
 
242
271
 
243
- class ScalarParameterType(SchemaModel):
272
+ class ScalarParameterType(ParameterType[ScalarType]):
244
273
  main: ScalarType = Field(description="The main data type of the parameter.")
245
274
 
246
275
 
247
- ParameterType = (
276
+ ParameterTypeUnion = (
248
277
  ArrayParameterType
249
278
  | ObjectParameterType
250
279
  | BlockParameterType
@@ -351,7 +380,7 @@ class ParameterDefinition(SchemaModel):
351
380
  None,
352
381
  description="The maximum value for the parameter if it is a number. Needs type.main to be 'float' or 'integer' to be applicable.",
353
382
  )
354
- data_type: ParameterType | None = Field(
383
+ data_type: ParameterTypeUnion | None = Field(
355
384
  None,
356
385
  alias="type",
357
386
  description="The data type of the parameter.",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pz-scripts-data
3
- Version: 1.1.2
3
+ Version: 1.2.0
4
4
  Summary: Dataset for the Scripts of Project Zomboid.
5
5
  Author: SimKDT
6
6
  License-Expression: MIT
@@ -1,6 +0,0 @@
1
- from enum import StrEnum
2
-
3
- class PropertyData(StrEnum):
4
- NAME = 'name'
5
- DESCRIPTION = 'description'
6
- PROPERTIES = 'properties'
File without changes