pz-scripts-data 1.1.2__tar.gz → 1.3.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.3.0}/PKG-INFO +1 -1
  2. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/pyproject.toml +1 -1
  3. pz_scripts_data-1.3.0/src/pz_scripts_data/blocks.py +65 -0
  4. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/formatBlocks.py +7 -1
  5. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/schema.py +69 -16
  6. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0/src/pz_scripts_data.egg-info}/PKG-INFO +1 -1
  7. pz_scripts_data-1.1.2/src/pz_scripts_data/blocks.py +0 -6
  8. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/LICENSE +0 -0
  9. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/README.md +0 -0
  10. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/setup.cfg +0 -0
  11. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/py.typed +0 -0
  12. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/release.py +0 -0
  13. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/sortItemParameters.py +0 -0
  14. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data/validateBlocks.py +0 -0
  15. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data.egg-info/SOURCES.txt +0 -0
  16. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data.egg-info/dependency_links.txt +0 -0
  17. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data.egg-info/entry_points.txt +0 -0
  18. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.0}/src/pz_scripts_data.egg-info/requires.txt +0 -0
  19. {pz_scripts_data-1.1.2 → pz_scripts_data-1.3.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.3.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.3.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'
@@ -62,7 +62,7 @@ items: list[Item] = [
62
62
  def fetchBlocks(item: Item):
63
63
  # combine all block yaml files into one, validating each against the schema
64
64
  blocks: dict[str, ScriptsBlock] = {}
65
- for file_path in item['input'].glob("*.yaml"):
65
+ for file_path in sorted(item['input'].glob("*.yaml")):
66
66
  with open(file_path, 'r', encoding='utf-8') as f:
67
67
  data = yaml.safe_load(f)
68
68
  try:
@@ -255,6 +255,12 @@ def prepare(item: Item, items: list[Item]):
255
255
  copy_block_ref(block, items)
256
256
  copy_parameters_ref(block.parameters, items)
257
257
 
258
+ # children and variants are appended in processing order, so sort them for stable output
259
+ for block in blocks.values():
260
+ if block.children:
261
+ block.children.sort()
262
+ if block.variants:
263
+ block.variants.sort()
258
264
 
259
265
  return blocks
260
266
 
@@ -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,32 @@ 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
+ FileType = Literal["file"]
34
+ ParameterMainType = (
35
+ ScalarType
36
+ | TranslationType
37
+ | CallBackType
38
+ | BlockType
39
+ | ObjectType
40
+ | ArrayType
41
+ | FileType
42
+ )
43
+
19
44
 
20
45
  # Accepts whole numbers as int so they are not widened to float on output. The JSON Schema stays "number".
21
46
  Number = Annotated[int | float, WithJsonSchema({"type": "number"})]
@@ -109,6 +134,21 @@ class BlockDeprecation(SchemaModel):
109
134
  description="A brief description of why the block type is deprecated and any additional information about the deprecation.",
110
135
  )
111
136
 
137
+ class FileDefinition(SchemaModel):
138
+ """Describes the expected format of a file parameter."""
139
+
140
+ relative_to: str = Field(
141
+ description="The relative path of the file, relative to version and common folders.",
142
+ alias="relativeTo",
143
+ )
144
+ prefix: str | None = Field(
145
+ None,
146
+ description="An optional prefix for the file path.",
147
+ )
148
+ extension: str = Field(
149
+ description="The file extension for the file parameter.",
150
+ )
151
+
112
152
 
113
153
  class _ArrayBase(SchemaModel):
114
154
  separator: str = Field(description="Specifies the separator used to split the string into array items.")
@@ -206,50 +246,63 @@ class CallbackDefinition(SchemaModel):
206
246
  returns: str | None = Field(None, description="The return type of the callback function.")
207
247
 
208
248
 
209
- class ArrayParameterType(SchemaModel):
210
- main: Literal["array"] = Field(description="The main data type of the parameter.")
249
+ T = TypeVar('T')
250
+ class ParameterType(SchemaModel, Generic[T]):
251
+ """Represents the type of a parameter."""
252
+ main: T = Field(description="The main data type of the parameter.")
253
+
254
+
255
+ class ArrayParameterType(ParameterType[ArrayType]):
256
+ main: ArrayType = Field(description="The main data type of the parameter.")
211
257
  array: ArrayDefinition = Field(
212
258
  description="If the parameter is of type 'array', this can be used to provide a description of the expected format of the array.",
213
259
  )
214
260
 
215
261
 
216
- class ObjectParameterType(SchemaModel):
217
- main: Literal["object"] = Field(description="The main data type of the parameter.")
218
- object_: ObjectDefinition = Field(
262
+ class ObjectParameterType(ParameterType[ObjectType]):
263
+ main: ObjectType = Field(description="The main data type of the parameter.")
264
+ object: ObjectDefinition = Field(
219
265
  alias="object",
220
266
  description="If the parameter is of type 'object', this can be used to provide a description of the expected format of the object.",
221
267
  )
222
268
 
223
269
 
224
- class BlockParameterType(SchemaModel):
225
- main: Literal["block"] = Field(description="The main data type of the parameter.")
270
+ class BlockParameterType(ParameterType[BlockType]):
271
+ main: BlockType = Field(description="The main data type of the parameter.")
226
272
  block: BlockReference = Field(
227
273
  description="If the parameter is of type 'block', this can be used to provide a description of the expected format of the block.",
228
274
  )
229
275
 
230
276
 
231
- class CallbackParameterType(SchemaModel):
232
- main: Literal["callback"] = Field(description="The main data type of the parameter.")
277
+ class CallbackParameterType(ParameterType[CallBackType]):
278
+ main: CallBackType = Field(description="The main data type of the parameter.")
233
279
  callback: CallbackDefinition = Field(description="Indicates whether the parameter is a callback function.")
234
280
 
235
281
 
236
- class TranslationParameterType(SchemaModel):
237
- main: Literal["translation"] = Field(description="The main data type of the parameter.")
282
+ class TranslationParameterType(ParameterType[TranslationType]):
283
+ main: TranslationType = Field(description="The main data type of the parameter.")
238
284
  translation: TranslationDefinition = Field(
239
285
  description="If the parameter is of type 'translation', this can be used to provide a description of the expected format of the translation.",
240
286
  )
241
287
 
288
+ class FileParameterType(ParameterType[FileType]):
289
+ main: FileType = Field(description="The main data type of the parameter.")
290
+ file: FileDefinition = Field(
291
+ description="If the parameter is of type 'file', this can be used to provide a description of the expected format of the file.",
292
+ )
293
+
242
294
 
243
- class ScalarParameterType(SchemaModel):
295
+ class ScalarParameterType(ParameterType[ScalarType]):
244
296
  main: ScalarType = Field(description="The main data type of the parameter.")
245
297
 
246
298
 
247
- ParameterType = (
299
+ ParameterTypeUnion = (
248
300
  ArrayParameterType
249
301
  | ObjectParameterType
250
302
  | BlockParameterType
251
303
  | CallbackParameterType
252
304
  | TranslationParameterType
305
+ | FileParameterType
253
306
  | ScalarParameterType
254
307
  )
255
308
 
@@ -351,7 +404,7 @@ class ParameterDefinition(SchemaModel):
351
404
  None,
352
405
  description="The maximum value for the parameter if it is a number. Needs type.main to be 'float' or 'integer' to be applicable.",
353
406
  )
354
- data_type: ParameterType | None = Field(
407
+ data_type: ParameterTypeUnion | None = Field(
355
408
  None,
356
409
  alias="type",
357
410
  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.3.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