amulet-core 2.0a7__cp312-cp312-win_amd64.whl → 2.0.1a2.post250529084747__cp312-cp312-win_amd64.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.
Potentially problematic release.
This version of amulet-core might be problematic. Click here for more details.
- amulet/core/__init__.py +36 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cp312-win_amd64.pyd +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/{_version.py → core/_version.py} +3 -3
- amulet/core/amulet_core.dll +0 -0
- amulet/core/amulet_core.lib +0 -0
- amulet/core/amulet_coreConfig.cmake +18 -0
- amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
- amulet/core/biome/biome.hpp +53 -0
- amulet/{block.pyi → core/block/__init__.pyi} +25 -26
- amulet/core/block/block.hpp +156 -0
- amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +18 -0
- amulet/core/chunk/component/biome_3d_component.hpp +96 -0
- amulet/core/chunk/component/block_component.hpp +101 -0
- amulet/core/chunk/component/block_component.pyi +28 -0
- amulet/core/chunk/component/block_entity_component.hpp +119 -0
- amulet/core/chunk/component/section_array_map.hpp +129 -0
- amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/{palette → core/palette}/__init__.pyi +2 -2
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/{palette → core/palette}/biome_palette.pyi +8 -8
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/{palette → core/palette}/block_palette.pyi +12 -10
- amulet/core/selection/__init__.pyi +8 -0
- amulet/core/selection/box.hpp +86 -0
- amulet/core/selection/box.pyi +215 -0
- amulet/core/selection/group.hpp +80 -0
- amulet/core/selection/group.pyi +213 -0
- amulet/{version.pyi → core/version/__init__.pyi} +58 -10
- amulet/core/version/version.hpp +204 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084747.dist-info}/METADATA +25 -20
- amulet_core-2.0.1a2.post250529084747.dist-info/RECORD +45 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084747.dist-info}/WHEEL +1 -1
- amulet_core-2.0.1a2.post250529084747.dist-info/entry_points.txt +2 -0
- amulet/__init__.cp312-win_amd64.pyd +0 -0
- amulet/__init__.py.cpp +0 -43
- amulet/__init__.pyi +0 -28
- amulet/__pyinstaller/hook-amulet.py +0 -4
- amulet/_init.py +0 -26
- amulet/biome.cpp +0 -36
- amulet/biome.hpp +0 -43
- amulet/biome.py.cpp +0 -122
- amulet/block.cpp +0 -435
- amulet/block.hpp +0 -119
- amulet/block.py.cpp +0 -377
- amulet/block_entity.cpp +0 -12
- amulet/block_entity.hpp +0 -56
- amulet/block_entity.py.cpp +0 -115
- amulet/chunk.cpp +0 -16
- amulet/chunk.hpp +0 -99
- amulet/chunk.py.cpp +0 -80
- amulet/chunk.pyi +0 -28
- amulet/chunk_components/biome_3d_component.cpp +0 -5
- amulet/chunk_components/biome_3d_component.hpp +0 -79
- amulet/chunk_components/block_component.cpp +0 -41
- amulet/chunk_components/block_component.hpp +0 -88
- amulet/chunk_components/block_entity_component.cpp +0 -5
- amulet/chunk_components/block_entity_component.hpp +0 -147
- amulet/chunk_components/section_array_map.cpp +0 -129
- amulet/chunk_components/section_array_map.hpp +0 -147
- amulet/collections/eq.py.hpp +0 -37
- amulet/collections/hash.py.hpp +0 -27
- amulet/collections/holder.py.hpp +0 -37
- amulet/collections/iterator.py.hpp +0 -80
- amulet/collections/mapping.py.hpp +0 -199
- amulet/collections/mutable_mapping.py.hpp +0 -226
- amulet/collections/sequence.py.hpp +0 -163
- amulet/collections.pyi +0 -40
- amulet/data_types.py +0 -29
- amulet/entity.py +0 -182
- amulet/game/__init__.py +0 -7
- amulet/game/_game.py +0 -152
- amulet/game/_universal/__init__.py +0 -1
- amulet/game/_universal/_biome.py +0 -17
- amulet/game/_universal/_block.py +0 -47
- amulet/game/_universal/_version.py +0 -68
- amulet/game/abc/__init__.py +0 -22
- amulet/game/abc/_block_specification.py +0 -150
- amulet/game/abc/biome.py +0 -213
- amulet/game/abc/block.py +0 -331
- amulet/game/abc/game_version_container.py +0 -25
- amulet/game/abc/json_interface.py +0 -27
- amulet/game/abc/version.py +0 -44
- amulet/game/bedrock/__init__.py +0 -1
- amulet/game/bedrock/_biome.py +0 -35
- amulet/game/bedrock/_block.py +0 -42
- amulet/game/bedrock/_version.py +0 -165
- amulet/game/java/__init__.py +0 -2
- amulet/game/java/_biome.py +0 -35
- amulet/game/java/_block.py +0 -60
- amulet/game/java/_version.py +0 -176
- amulet/game/translate/__init__.py +0 -12
- amulet/game/translate/_functions/__init__.py +0 -15
- amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
- amulet/game/translate/_functions/_code_functions/_text.py +0 -553
- amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
- amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
- amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
- amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
- amulet/game/translate/_functions/_frozen.py +0 -66
- amulet/game/translate/_functions/_state.py +0 -54
- amulet/game/translate/_functions/_typing.py +0 -98
- amulet/game/translate/_functions/abc.py +0 -123
- amulet/game/translate/_functions/carry_nbt.py +0 -160
- amulet/game/translate/_functions/carry_properties.py +0 -80
- amulet/game/translate/_functions/code.py +0 -143
- amulet/game/translate/_functions/map_block_name.py +0 -66
- amulet/game/translate/_functions/map_nbt.py +0 -111
- amulet/game/translate/_functions/map_properties.py +0 -93
- amulet/game/translate/_functions/multiblock.py +0 -112
- amulet/game/translate/_functions/new_block.py +0 -42
- amulet/game/translate/_functions/new_entity.py +0 -43
- amulet/game/translate/_functions/new_nbt.py +0 -206
- amulet/game/translate/_functions/new_properties.py +0 -64
- amulet/game/translate/_functions/sequence.py +0 -51
- amulet/game/translate/_functions/walk_input_nbt.py +0 -331
- amulet/game/translate/_translator.py +0 -433
- amulet/img/__init__.py +0 -10
- amulet/img/missing_no.png +0 -0
- amulet/img/missing_pack.png +0 -0
- amulet/img/missing_world.png +0 -0
- amulet/io/binary_reader.hpp +0 -45
- amulet/io/binary_writer.hpp +0 -30
- amulet/item.py +0 -75
- amulet/level/__init__.pyi +0 -23
- amulet/level/_load.py +0 -100
- amulet/level/abc/__init__.py +0 -12
- amulet/level/abc/_chunk_handle.py +0 -335
- amulet/level/abc/_dimension.py +0 -86
- amulet/level/abc/_history/__init__.py +0 -1
- amulet/level/abc/_history/_cache.py +0 -224
- amulet/level/abc/_history/_history_manager.py +0 -291
- amulet/level/abc/_level/__init__.py +0 -5
- amulet/level/abc/_level/_compactable_level.py +0 -10
- amulet/level/abc/_level/_creatable_level.py +0 -28
- amulet/level/abc/_level/_disk_level.py +0 -17
- amulet/level/abc/_level/_level.py +0 -449
- amulet/level/abc/_level/_loadable_level.py +0 -42
- amulet/level/abc/_player_storage.py +0 -7
- amulet/level/abc/_raw_level.py +0 -187
- amulet/level/abc/_registry.py +0 -40
- amulet/level/java/__init__.pyi +0 -16
- amulet/level/java/_chunk_handle.py +0 -17
- amulet/level/java/_dimension.py +0 -20
- amulet/level/java/_level.py +0 -184
- amulet/level/java/_raw/__init__.pyi +0 -15
- amulet/level/java/_raw/_chunk.pyi +0 -23
- amulet/level/java/_raw/_constant.py +0 -9
- amulet/level/java/_raw/_data_pack/__init__.py +0 -2
- amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
- amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
- amulet/level/java/_raw/_dimension.py +0 -86
- amulet/level/java/_raw/_level.py +0 -507
- amulet/level/java/_raw/_typing.py +0 -3
- amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
- amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
- amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
- amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
- amulet/level/java/anvil/__init__.py +0 -2
- amulet/level/java/anvil/_dimension.py +0 -170
- amulet/level/java/anvil/_region.py +0 -421
- amulet/level/java/anvil/_sector_manager.py +0 -223
- amulet/level/java/chunk.pyi +0 -81
- amulet/level/java/chunk_/_chunk.py +0 -260
- amulet/level/java/chunk_/components/inhabited_time.py +0 -12
- amulet/level/java/chunk_/components/last_update.py +0 -12
- amulet/level/java/chunk_/components/legacy_version.py +0 -12
- amulet/level/java/chunk_/components/light_populated.py +0 -12
- amulet/level/java/chunk_/components/named_height_2d.py +0 -37
- amulet/level/java/chunk_/components/status.py +0 -11
- amulet/level/java/chunk_/components/terrain_populated.py +0 -12
- amulet/level/java/chunk_components/data_version_component.cpp +0 -32
- amulet/level/java/chunk_components/data_version_component.hpp +0 -31
- amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
- amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
- amulet/level/java/chunk_components.pyi +0 -22
- amulet/level/java/java_chunk.cpp +0 -170
- amulet/level/java/java_chunk.hpp +0 -141
- amulet/level/java/long_array.hpp +0 -175
- amulet/level/java/long_array.pyi +0 -39
- amulet/level/temporary_level/__init__.py +0 -1
- amulet/level/temporary_level/_level.py +0 -16
- amulet/mesh/__init__.py +0 -0
- amulet/mesh/block/__init__.py +0 -1
- amulet/mesh/block/block_mesh.py +0 -369
- amulet/mesh/block/cube.py +0 -149
- amulet/mesh/block/missing_block.py +0 -20
- amulet/mesh/util.py +0 -17
- amulet/palette/biome_palette.hpp +0 -85
- amulet/palette/block_palette.cpp +0 -32
- amulet/palette/block_palette.hpp +0 -93
- amulet/player.py +0 -62
- amulet/pybind11/collections.hpp +0 -118
- amulet/pybind11/numpy.hpp +0 -26
- amulet/pybind11/py_module.hpp +0 -34
- amulet/pybind11/type_hints.hpp +0 -51
- amulet/pybind11/types.hpp +0 -25
- amulet/pybind11/typing.hpp +0 -7
- amulet/resource_pack/__init__.py +0 -62
- amulet/resource_pack/abc/__init__.py +0 -2
- amulet/resource_pack/abc/resource_pack.py +0 -38
- amulet/resource_pack/abc/resource_pack_manager.py +0 -87
- amulet/resource_pack/bedrock/__init__.py +0 -2
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/pack_icon.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_carried.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_side_carried.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/water.png +0 -0
- amulet/resource_pack/bedrock/blockshapes/__init__.py +0 -31
- amulet/resource_pack/bedrock/blockshapes/air.py +0 -35
- amulet/resource_pack/bedrock/blockshapes/base_blockshape.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/bubble_column.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/cake.py +0 -46
- amulet/resource_pack/bedrock/blockshapes/chest.py +0 -54
- amulet/resource_pack/bedrock/blockshapes/comparator.py +0 -51
- amulet/resource_pack/bedrock/blockshapes/cross_texture.py +0 -186
- amulet/resource_pack/bedrock/blockshapes/cross_texture0.py +0 -17
- amulet/resource_pack/bedrock/blockshapes/cross_texture_green.py +0 -16
- amulet/resource_pack/bedrock/blockshapes/cube.py +0 -38
- amulet/resource_pack/bedrock/blockshapes/default.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door.py +0 -38
- amulet/resource_pack/bedrock/blockshapes/door1.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door2.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door3.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door4.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door5.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door6.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/double_plant.py +0 -40
- amulet/resource_pack/bedrock/blockshapes/enchanting_table.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/farmland.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/fence.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/flat.py +0 -55
- amulet/resource_pack/bedrock/blockshapes/flat_wall.py +0 -55
- amulet/resource_pack/bedrock/blockshapes/furnace.py +0 -44
- amulet/resource_pack/bedrock/blockshapes/furnace_lit.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/green_cube.py +0 -39
- amulet/resource_pack/bedrock/blockshapes/ladder.py +0 -36
- amulet/resource_pack/bedrock/blockshapes/lilypad.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/partial_block.py +0 -57
- amulet/resource_pack/bedrock/blockshapes/piston.py +0 -44
- amulet/resource_pack/bedrock/blockshapes/piston_arm.py +0 -72
- amulet/resource_pack/bedrock/blockshapes/portal_frame.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/pressure_plate.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/pumpkin.py +0 -36
- amulet/resource_pack/bedrock/blockshapes/pumpkin_carved.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/pumpkin_lit.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/red_dust.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/repeater.py +0 -53
- amulet/resource_pack/bedrock/blockshapes/slab.py +0 -33
- amulet/resource_pack/bedrock/blockshapes/slab_double.py +0 -15
- amulet/resource_pack/bedrock/blockshapes/tree.py +0 -41
- amulet/resource_pack/bedrock/blockshapes/turtle_egg.py +0 -15
- amulet/resource_pack/bedrock/blockshapes/vine.py +0 -52
- amulet/resource_pack/bedrock/blockshapes/wall.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/water.py +0 -38
- amulet/resource_pack/bedrock/download_resources.py +0 -147
- amulet/resource_pack/bedrock/resource_pack.py +0 -40
- amulet/resource_pack/bedrock/resource_pack_manager.py +0 -361
- amulet/resource_pack/bedrock/sort_blockshapes.py +0 -15
- amulet/resource_pack/java/__init__.py +0 -2
- amulet/resource_pack/java/download_resources.py +0 -212
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
- amulet/resource_pack/java/resource_pack.py +0 -44
- amulet/resource_pack/java/resource_pack_manager.py +0 -551
- amulet/resource_pack/unknown_resource_pack.py +0 -10
- amulet/selection/__init__.py +0 -2
- amulet/selection/abstract_selection.py +0 -342
- amulet/selection/box.py +0 -852
- amulet/selection/group.py +0 -481
- amulet/utils/__init__.pyi +0 -23
- amulet/utils/call_spec/__init__.py +0 -24
- amulet/utils/call_spec/_call_spec.py +0 -257
- amulet/utils/comment_json.py +0 -188
- amulet/utils/format_utils.py +0 -41
- amulet/utils/generator.py +0 -18
- amulet/utils/matrix.py +0 -243
- amulet/utils/numpy.hpp +0 -36
- amulet/utils/numpy.pyi +0 -11
- amulet/utils/numpy_helpers.py +0 -19
- amulet/utils/shareable_lock.py +0 -335
- amulet/utils/signal/__init__.py +0 -10
- amulet/utils/signal/_signal.py +0 -228
- amulet/utils/task_manager.py +0 -235
- amulet/utils/typed_property.py +0 -111
- amulet/utils/weakref.py +0 -70
- amulet/utils/world_utils.py +0 -102
- amulet/version.cpp +0 -136
- amulet/version.hpp +0 -142
- amulet/version.py.cpp +0 -281
- amulet_core-2.0a7.dist-info/RECORD +0 -295
- amulet_core-2.0a7.dist-info/entry_points.txt +0 -2
- /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
- /amulet/{py.typed → core/py.typed} +0 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084747.dist-info}/top_level.txt +0 -0
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"""This modules contains classes to notify other code of the call specification for a function.
|
|
2
|
-
The aim is to support generating GUIs without having to manually program a GUI to handle the function call.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
from typing import (
|
|
8
|
-
Any,
|
|
9
|
-
Callable,
|
|
10
|
-
Protocol,
|
|
11
|
-
TypeVar,
|
|
12
|
-
cast,
|
|
13
|
-
ParamSpec,
|
|
14
|
-
overload,
|
|
15
|
-
Concatenate,
|
|
16
|
-
runtime_checkable,
|
|
17
|
-
)
|
|
18
|
-
from collections.abc import Sequence, Hashable
|
|
19
|
-
from abc import ABC
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class AbstractArg(ABC):
|
|
23
|
-
"""The base class for all arguments."""
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class AbstractHashableArg(AbstractArg, ABC):
|
|
27
|
-
"""A base class for all arguments that are hashable."""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class DocumentationArg(AbstractArg):
|
|
31
|
-
"""A way to add documentation for an argument."""
|
|
32
|
-
|
|
33
|
-
def __init__(
|
|
34
|
-
self, arg: AbstractArg, name: str | None = None, description: str | None = None
|
|
35
|
-
) -> None:
|
|
36
|
-
"""Construct a DocumentationArg instance.
|
|
37
|
-
|
|
38
|
-
:param arg: The argument this documentation relates to.
|
|
39
|
-
:param name: The short name for the argument.
|
|
40
|
-
:param description: A longer description for the argument.
|
|
41
|
-
"""
|
|
42
|
-
self.arg = arg
|
|
43
|
-
self.name = name
|
|
44
|
-
self.description = description
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class ConstantArg(AbstractArg):
|
|
48
|
-
"""A constant argument.
|
|
49
|
-
Use this for fixed values.
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
def __init__(self, value: Any) -> None:
|
|
53
|
-
self.value = value
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class StringArg(AbstractHashableArg):
|
|
57
|
-
"""A string argument"""
|
|
58
|
-
|
|
59
|
-
def __init__(self, default: str = "") -> None:
|
|
60
|
-
self.default = default
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class FilePathArg(StringArg):
|
|
64
|
-
"""A path to a file on disk. Converts to a string."""
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class DirectoryPathArg(StringArg):
|
|
68
|
-
"""A path to a directory on disk. Converts to a string."""
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class BytesArg(AbstractHashableArg):
|
|
72
|
-
"""A bytes argument"""
|
|
73
|
-
|
|
74
|
-
def __init__(self, default: bytes = b"") -> None:
|
|
75
|
-
self.default = default
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
class BoolArg(AbstractHashableArg):
|
|
79
|
-
"""A bool argument"""
|
|
80
|
-
|
|
81
|
-
def __init__(self, default: bool = False) -> None:
|
|
82
|
-
self.default = default
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class IntArg(AbstractHashableArg):
|
|
86
|
-
"""An int argument"""
|
|
87
|
-
|
|
88
|
-
def __init__(
|
|
89
|
-
self,
|
|
90
|
-
default: int = 0,
|
|
91
|
-
min_value: int | None = None,
|
|
92
|
-
max_value: int | None = None,
|
|
93
|
-
) -> None:
|
|
94
|
-
self.default = default
|
|
95
|
-
self.min_value = min_value
|
|
96
|
-
self.max_value = max_value
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class FloatArg(AbstractHashableArg):
|
|
100
|
-
"""A float argument"""
|
|
101
|
-
|
|
102
|
-
def __init__(
|
|
103
|
-
self,
|
|
104
|
-
default: float = 0,
|
|
105
|
-
min_value: float | None = None,
|
|
106
|
-
max_value: float | None = None,
|
|
107
|
-
) -> None:
|
|
108
|
-
self.default = default
|
|
109
|
-
self.min_value = min_value
|
|
110
|
-
self.max_value = max_value
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
class TupleArg(AbstractArg):
|
|
114
|
-
"""A tuple argument"""
|
|
115
|
-
|
|
116
|
-
def __init__(self, *args: AbstractArg) -> None:
|
|
117
|
-
self.args = args
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
class HashableTupleArg(AbstractArg):
|
|
121
|
-
"""A tuple argument where all elements are hashable."""
|
|
122
|
-
|
|
123
|
-
def __init__(self, *args: AbstractHashableArg) -> None:
|
|
124
|
-
self.args = args
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
class SequenceArg(AbstractArg):
|
|
128
|
-
"""
|
|
129
|
-
A sequence of other arguments.
|
|
130
|
-
Each element must match element_type.
|
|
131
|
-
length must be a positive integer for a fixed length or None for unbounded length.
|
|
132
|
-
"""
|
|
133
|
-
|
|
134
|
-
def __init__(
|
|
135
|
-
self,
|
|
136
|
-
element_type: AbstractArg,
|
|
137
|
-
default: Sequence[AbstractArg] = (),
|
|
138
|
-
min_length: int | None = None,
|
|
139
|
-
max_length: int | None = None,
|
|
140
|
-
) -> None:
|
|
141
|
-
self.element_type = element_type
|
|
142
|
-
self.default = default
|
|
143
|
-
self.min_length = min_length
|
|
144
|
-
self.max_length = max_length
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
class PositionalArgs(SequenceArg):
|
|
148
|
-
"""A sequence of arguments that should be unpacked into the container.
|
|
149
|
-
This is useful when a CallableArg can take a variable number of an argument.
|
|
150
|
-
"""
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
class DictArg(AbstractArg):
|
|
154
|
-
"""A dictionary argument"""
|
|
155
|
-
|
|
156
|
-
def __init__(self, key: AbstractHashableArg, value: AbstractArg) -> None:
|
|
157
|
-
self.key = key
|
|
158
|
-
self.value = value
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
class UnionArg(AbstractArg):
|
|
162
|
-
"""The object must match one of the types in args"""
|
|
163
|
-
|
|
164
|
-
def __init__(self, *args: AbstractArg) -> None:
|
|
165
|
-
self.args = args
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
class HashableUnionArg(AbstractArg):
|
|
169
|
-
"""The object must match one of the types in args"""
|
|
170
|
-
|
|
171
|
-
def __init__(self, *args: AbstractHashableArg) -> None:
|
|
172
|
-
self.args = args
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
class CallableArg(AbstractArg):
|
|
176
|
-
"""An argument generated by a function.
|
|
177
|
-
This can be used to create instances of classes.
|
|
178
|
-
kwargs specify the arguments to pass to the function.
|
|
179
|
-
"""
|
|
180
|
-
|
|
181
|
-
def __init__(
|
|
182
|
-
self, func: Callable[..., Any], *args: AbstractArg, **kwargs: AbstractArg
|
|
183
|
-
) -> None:
|
|
184
|
-
self.func = func
|
|
185
|
-
self.call_spec = CallSpec(*args, **kwargs)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
class HashableCallableArg(AbstractHashableArg):
|
|
189
|
-
"""An argument generated by a function.
|
|
190
|
-
This can be used to create instances of classes.
|
|
191
|
-
kwargs specify the arguments to pass to the function.
|
|
192
|
-
"""
|
|
193
|
-
|
|
194
|
-
def __init__(self, func: Callable[..., Hashable], call_spec: CallSpec) -> None:
|
|
195
|
-
self.func = func
|
|
196
|
-
self.call_spec = call_spec
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
class CallSpec:
|
|
200
|
-
"""Arguments and keyword arguments that should be unpacked to call a function."""
|
|
201
|
-
|
|
202
|
-
def __init__(self, *args: AbstractArg, **kwargs: AbstractArg) -> None:
|
|
203
|
-
self.args = args
|
|
204
|
-
self.kwargs = kwargs
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
# The following is a really janky workaround to add a variable to a function or method in a way that mypy likes.
|
|
208
|
-
# This would be made so much simpler if Python had an Intersection type hint.
|
|
209
|
-
|
|
210
|
-
P = ParamSpec("P")
|
|
211
|
-
R = TypeVar("R", covariant=True)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
@runtime_checkable
|
|
215
|
-
class TypedCallable(Protocol[P, R]):
|
|
216
|
-
call_spec: CallSpec
|
|
217
|
-
|
|
218
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R: ...
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@runtime_checkable
|
|
222
|
-
class TypedMethod(Protocol[P, R]):
|
|
223
|
-
call_spec: CallSpec
|
|
224
|
-
|
|
225
|
-
def __call__(self, self_: Any, *args: P.args, **kwargs: P.kwargs) -> R: ...
|
|
226
|
-
|
|
227
|
-
@overload
|
|
228
|
-
def __get__(self, instance: None, owner: None) -> TypedMethod[P, R]: ...
|
|
229
|
-
|
|
230
|
-
@overload
|
|
231
|
-
def __get__(self, instance: object, owner: object) -> TypedCallable[P, R]: ...
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
def callable_spec(
|
|
235
|
-
*args: AbstractArg, **kwargs: AbstractArg
|
|
236
|
-
) -> Callable[[Callable[P, R]], TypedCallable[P, R]]:
|
|
237
|
-
call_spec: CallSpec = CallSpec(*args, **kwargs)
|
|
238
|
-
|
|
239
|
-
def wrap(func: Callable[P, R]) -> TypedCallable[P, R]:
|
|
240
|
-
func_ = cast(TypedCallable[P, R], func)
|
|
241
|
-
func_.call_spec = call_spec
|
|
242
|
-
return func_
|
|
243
|
-
|
|
244
|
-
return wrap
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
def method_spec(
|
|
248
|
-
*args: AbstractArg, **kwargs: AbstractArg
|
|
249
|
-
) -> Callable[[Callable[Concatenate[Any, P], R]], TypedMethod[P, R]]:
|
|
250
|
-
call_spec: CallSpec = CallSpec(*args, **kwargs)
|
|
251
|
-
|
|
252
|
-
def wrap(func: Callable[Concatenate[Any, P], R]) -> TypedMethod[P, R]:
|
|
253
|
-
func_ = cast(TypedMethod[P, R], func)
|
|
254
|
-
func_.call_spec = call_spec
|
|
255
|
-
return func_
|
|
256
|
-
|
|
257
|
-
return wrap
|
amulet/utils/comment_json.py
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
from json import JSONDecodeError, loads as json_loads
|
|
2
|
-
from typing import TextIO, Union
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
Some of the Bedrock json files contain comments which is not valid JSON and the standard json parser
|
|
6
|
-
will throw errors. This will first try and use the vanilla json parser and fall back to the slower version if that fails.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
JSONValue = Union[str, int, float, bool, None, "JSONDict", "JSONList"]
|
|
11
|
-
JSONDict = dict[str, JSONValue]
|
|
12
|
-
JSONList = list[JSONValue]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CommentJSONDecodeError(JSONDecodeError):
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def from_file(path: str) -> JSONValue:
|
|
20
|
-
with open(path) as f:
|
|
21
|
-
return load(f)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def load(obj: TextIO) -> JSONValue:
|
|
25
|
-
return loads(obj.read())
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def loads(s: str) -> JSONValue:
|
|
29
|
-
try:
|
|
30
|
-
return json_loads(s) # type: ignore
|
|
31
|
-
except JSONDecodeError:
|
|
32
|
-
return _loads(s)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def _loads(text: str) -> JSONValue:
|
|
36
|
-
# given a valid MinecraftJSON string will return the values as python objects
|
|
37
|
-
# in this context MinecraftJSON is standard JSON but with comment blocks and
|
|
38
|
-
# line comments that would normally be illegal in standard JSON
|
|
39
|
-
_number = set("0123456789-")
|
|
40
|
-
_float = set("0123456789-.")
|
|
41
|
-
_whitespace = set(" \t\r\n")
|
|
42
|
-
|
|
43
|
-
def strip_whitespace(index: int) -> int:
|
|
44
|
-
# skips whitespace characters (<space>, <tab>, <charrage return> and <newline>)
|
|
45
|
-
# as well as block comments and line comments
|
|
46
|
-
while text[index] in _whitespace:
|
|
47
|
-
index += 1
|
|
48
|
-
if text[index] == "/":
|
|
49
|
-
if text[index + 1] == "/":
|
|
50
|
-
index += 2
|
|
51
|
-
while text[index] != "\n":
|
|
52
|
-
index += 1
|
|
53
|
-
index = strip_whitespace(index)
|
|
54
|
-
elif text[index + 1] == "*":
|
|
55
|
-
index += 2
|
|
56
|
-
while text[index : index + 2] != "*/":
|
|
57
|
-
index += 1
|
|
58
|
-
if index + 1 >= len(text):
|
|
59
|
-
raise JSONDecodeError(
|
|
60
|
-
"expected */ but reached the end of file", text, index
|
|
61
|
-
)
|
|
62
|
-
index += 2
|
|
63
|
-
index = strip_whitespace(index)
|
|
64
|
-
else:
|
|
65
|
-
raise JSONDecodeError(f"unexpected / at index {index}", text, index)
|
|
66
|
-
return index
|
|
67
|
-
|
|
68
|
-
def parse_json_recursive(index: int = 0) -> tuple[JSONValue, int]:
|
|
69
|
-
index = strip_whitespace(index)
|
|
70
|
-
if text[index] == "{":
|
|
71
|
-
index += 1
|
|
72
|
-
# dictionary
|
|
73
|
-
json_obj = {}
|
|
74
|
-
repeat = True
|
|
75
|
-
while repeat:
|
|
76
|
-
index = strip_whitespace(index)
|
|
77
|
-
# }"
|
|
78
|
-
if text[index] == '"':
|
|
79
|
-
index += 1
|
|
80
|
-
key = ""
|
|
81
|
-
while text[index] != '"':
|
|
82
|
-
key += text[index]
|
|
83
|
-
index += 1
|
|
84
|
-
index += 1
|
|
85
|
-
|
|
86
|
-
index = strip_whitespace(index)
|
|
87
|
-
|
|
88
|
-
if text[index] == ":":
|
|
89
|
-
index += 1
|
|
90
|
-
else:
|
|
91
|
-
raise JSONDecodeError(
|
|
92
|
-
f"expected : got {text[index]} at index {index}",
|
|
93
|
-
text,
|
|
94
|
-
index,
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
index = strip_whitespace(index)
|
|
98
|
-
|
|
99
|
-
json_obj[key], index = parse_json_recursive(index)
|
|
100
|
-
|
|
101
|
-
index = strip_whitespace(index)
|
|
102
|
-
|
|
103
|
-
if text[index] == ",":
|
|
104
|
-
index += 1
|
|
105
|
-
else:
|
|
106
|
-
repeat = False
|
|
107
|
-
else:
|
|
108
|
-
repeat = False
|
|
109
|
-
|
|
110
|
-
if index >= len(text):
|
|
111
|
-
raise JSONDecodeError("expected } but reached end of file", text, index)
|
|
112
|
-
elif text[index] == "}":
|
|
113
|
-
index += 1
|
|
114
|
-
else:
|
|
115
|
-
raise JSONDecodeError(
|
|
116
|
-
f"expected }} got {text[index]} at index {index}", text, index
|
|
117
|
-
)
|
|
118
|
-
return json_obj, index
|
|
119
|
-
|
|
120
|
-
elif text[index] == "[":
|
|
121
|
-
index += 1
|
|
122
|
-
# list
|
|
123
|
-
json_array = []
|
|
124
|
-
index = strip_whitespace(index)
|
|
125
|
-
repeat = text[index] != "]"
|
|
126
|
-
while repeat:
|
|
127
|
-
val, index = parse_json_recursive(index)
|
|
128
|
-
json_array.append(val)
|
|
129
|
-
|
|
130
|
-
index = strip_whitespace(index)
|
|
131
|
-
|
|
132
|
-
if text[index] == ",":
|
|
133
|
-
index += 1
|
|
134
|
-
else:
|
|
135
|
-
repeat = False
|
|
136
|
-
index = strip_whitespace(index)
|
|
137
|
-
|
|
138
|
-
if index >= len(text):
|
|
139
|
-
raise JSONDecodeError("expected ] but reached end of file", text, index)
|
|
140
|
-
elif text[index] == "]":
|
|
141
|
-
index += 1
|
|
142
|
-
else:
|
|
143
|
-
raise JSONDecodeError(
|
|
144
|
-
f"expected ] got {text[index]} at index {index}", text, index
|
|
145
|
-
)
|
|
146
|
-
return json_array, index
|
|
147
|
-
|
|
148
|
-
elif text[index] == '"':
|
|
149
|
-
index += 1
|
|
150
|
-
# string
|
|
151
|
-
json_obj_list = []
|
|
152
|
-
while text[index] != '"':
|
|
153
|
-
json_obj_list.append(text[index])
|
|
154
|
-
index += 1
|
|
155
|
-
index += 1
|
|
156
|
-
return "".join(json_obj_list), index
|
|
157
|
-
|
|
158
|
-
elif text[index] in _number:
|
|
159
|
-
# number
|
|
160
|
-
json_obj_list = []
|
|
161
|
-
while text[index] in _float:
|
|
162
|
-
json_obj_list += text[index]
|
|
163
|
-
index += 1
|
|
164
|
-
if "." in json_obj_list:
|
|
165
|
-
return float("".join(json_obj_list)), index
|
|
166
|
-
else:
|
|
167
|
-
return int("".join(json_obj_list)), index
|
|
168
|
-
|
|
169
|
-
elif text[index] == "n" and text[index : index + 4] == "null":
|
|
170
|
-
index += 4
|
|
171
|
-
return None, index
|
|
172
|
-
|
|
173
|
-
elif text[index] == "t" and text[index : index + 4] == "true":
|
|
174
|
-
index += 4
|
|
175
|
-
return True, index
|
|
176
|
-
|
|
177
|
-
elif text[index] == "f" and text[index : index + 5] == "false":
|
|
178
|
-
index += 5
|
|
179
|
-
return False, index
|
|
180
|
-
else:
|
|
181
|
-
raise JSONDecodeError(
|
|
182
|
-
f'unexpected key {text[index]} at {index}. Expected {{, [, ", num, null, true or false',
|
|
183
|
-
text,
|
|
184
|
-
index,
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
# call recursive function and pass back python object
|
|
188
|
-
return parse_json_recursive()[0]
|
amulet/utils/format_utils.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import warnings
|
|
5
|
-
|
|
6
|
-
from amulet_nbt import read_nbt, NamedTag
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def check_all_exist(in_dir: str, *args: str) -> bool:
|
|
10
|
-
"""
|
|
11
|
-
Check that all files exist in a parent directory
|
|
12
|
-
|
|
13
|
-
:param in_dir: The parent directory
|
|
14
|
-
:param args: file or folder names to look for
|
|
15
|
-
:return: Boolean value indicating whether all were found
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
return all(os.path.exists(os.path.join(in_dir, child)) for child in args)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def check_one_exists(in_dir: str, *args: str) -> bool:
|
|
22
|
-
"""
|
|
23
|
-
Check that at least one file exists in a parent directory
|
|
24
|
-
|
|
25
|
-
:param in_dir: The parent directory
|
|
26
|
-
:param args: file or folder names to look for
|
|
27
|
-
:return: Boolean value indicating whether at least one was found
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
return any(os.path.exists(os.path.join(in_dir, child)) for child in args)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def load_leveldat(in_dir: str) -> NamedTag:
|
|
34
|
-
"""
|
|
35
|
-
Load the root tag of the level.dat file in the directory
|
|
36
|
-
|
|
37
|
-
:param in_dir: The world directory containing the level.dat file
|
|
38
|
-
:return: The NBT root tag
|
|
39
|
-
"""
|
|
40
|
-
warnings.warn("load_leveldat is depreciated.", DeprecationWarning)
|
|
41
|
-
return read_nbt(os.path.join(in_dir, "level.dat"))
|
amulet/utils/generator.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from typing import Generator, TypeVar, Any
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
T = TypeVar("T")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def generator_unpacker(gen: Generator[Any, Any, T]) -> T:
|
|
8
|
-
"""
|
|
9
|
-
Unpack a generator and return the value returned by the generator.
|
|
10
|
-
|
|
11
|
-
:param gen: The generator to unpack.
|
|
12
|
-
:return: The value that was returned by the generator.
|
|
13
|
-
"""
|
|
14
|
-
try:
|
|
15
|
-
while True:
|
|
16
|
-
next(gen)
|
|
17
|
-
except StopIteration as e:
|
|
18
|
-
return e.value # type: ignore
|