beet-observer 0.6.0__tar.gz → 0.6.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: beet-observer
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: A beet plugin to automatically generate overlays from previous datapacks
5
5
  License: MIT
6
6
  Author: BPR02
@@ -1,3 +1,3 @@
1
- __version__ = "0.6.0"
1
+ __version__ = "0.6.2"
2
2
 
3
3
  from .plugin import *
@@ -1,7 +1,7 @@
1
1
  from typing import Any
2
2
 
3
3
  import beet.contrib.worldgen as wg
4
- from beet import Context, NamespaceProxy
4
+ from beet import Context, NamespaceProxy, Structure
5
5
 
6
6
 
7
7
  def gen_dp_overlays(
@@ -124,11 +124,6 @@ def gen_dp_overlays(
124
124
  continue
125
125
  # check if it's the top-level overlay
126
126
  if overlay == ctx.meta["observer"]["default_dir_dp"]:
127
- # delete pack.mcmeta from overlay (required for tests)
128
- default_dir = ctx.meta["observer"]["default_dir_dp"]
129
- if ctx.data.overlays[default_dir].mcmeta:
130
- del ctx.data.overlays[default_dir].mcmeta
131
-
132
127
  # get pack format from build context
133
128
  if "default_format" in ctx.meta["observer"]:
134
129
  formats = ctx.meta["observer"]["default_format"]
@@ -219,6 +214,10 @@ def gen_registry_overlay(
219
214
  else:
220
215
  # check if files are exactly the same
221
216
  try:
217
+ if isinstance(registry[name], Structure):
218
+ registry_overlay[name].data["DataVersion"] = registry[name].data[
219
+ "DataVersion"
220
+ ]
222
221
  if registry[name].data != registry_overlay[name].data:
223
222
  # move file from overlay pack to overlay in build pack
224
223
  ctx.data.overlays[overlay_dir][name] = registry_overlay[name]
@@ -7,6 +7,26 @@ from .resource_pack import *
7
7
  def beet_default(ctx: Context):
8
8
  if "observer" not in ctx.meta:
9
9
  return
10
+
11
+ # # check cache
12
+ cache = ctx.cache["observer"]
13
+ cached_dp = False
14
+ cached_rp = False
15
+ dp_path = None
16
+ rp_path = None
17
+ if ctx.data:
18
+ dp_path = cache.get_path(f"{ctx.directory} saved_data_pack")
19
+ if dp_path.is_dir():
20
+ ctx.data.load(f"{dp_path}")
21
+ cached_dp = True
22
+ if ctx.assets:
23
+ rp_path = cache.get_path(f"{ctx.directory} saved_resource_pack")
24
+ if rp_path.is_dir():
25
+ ctx.assets.load(f"{rp_path}")
26
+ cached_rp = True
27
+ if cached_dp and cached_rp:
28
+ return
29
+
10
30
  # get default directories
11
31
  if "default_dir" not in ctx.meta["observer"]:
12
32
  # default dir not defined
@@ -46,5 +66,13 @@ def beet_default(ctx: Context):
46
66
  dp_dir = overlay["directory"]
47
67
  rp_dir = overlay["directory"]
48
68
  # compare build pack and overlay pack
49
- gen_dp_overlays(ctx, ctx_overlay, dp_dir, save)
50
- gen_rp_overlays(ctx, ctx_overlay, rp_dir, save)
69
+ if not cached_dp and ctx.data:
70
+ gen_dp_overlays(ctx, ctx_overlay, dp_dir, save)
71
+ if not cached_rp and ctx.assets:
72
+ gen_rp_overlays(ctx, ctx_overlay, rp_dir, save)
73
+
74
+ # save to cache
75
+ if not cached_dp and ctx.data:
76
+ ctx.data.save(path=dp_path)
77
+ if not cached_rp and ctx.assets:
78
+ ctx.assets.save(path=rp_path)
@@ -52,11 +52,6 @@ def gen_rp_overlays(
52
52
  continue
53
53
  # check if it's the top-level overlay
54
54
  if overlay == ctx.meta["observer"]["default_dir_rp"]:
55
- # delete pack.mcmeta from overlay (required for tests)
56
- default_dir = ctx.meta["observer"]["default_dir_rp"]
57
- if ctx.assets.overlays[default_dir].mcmeta:
58
- del ctx.assets.overlays[default_dir].mcmeta
59
-
60
55
  # get pack format from build context
61
56
  if "default_format" in ctx.meta["observer"]:
62
57
  formats = ctx.meta["observer"]["default_format"]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "beet-observer"
3
- version = "0.6.0"
3
+ version = "0.6.2"
4
4
  description = "A beet plugin to automatically generate overlays from previous datapacks"
5
5
  authors = ["BPR02 <dev@bpr02.com>"]
6
6
  license = "MIT"
File without changes
File without changes