beet-observer 0.7.0__tar.gz → 0.7.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.7.0
3
+ Version: 0.7.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.7.0"
1
+ __version__ = "0.7.2"
2
2
 
3
3
  from .plugin import *
@@ -10,10 +10,11 @@ def gen_dp_overlays(
10
10
  """
11
11
  Generates overlays between two datapacks.
12
12
 
13
- Keyword arguments:</br>
14
- `ctx` -- the build context</br>
15
- `ctx_overlay` -- the overlay context</br>
16
- `overlay_dir` -- the directory of the overlay</br>
13
+ Keyword arguments: \n
14
+ `ctx` -- the build context \n
15
+ `ctx_overlay` -- the overlay context \n
16
+ `overlay_dir` -- the directory of the overlay \n
17
+ `ignore` -- a list of overlays to ignore (existing overlays that should not be touched) \n
17
18
  """
18
19
  # create list of all datapack file types
19
20
  file_types: list[tuple[NamespaceProxy[Any], NamespaceProxy[Any]]] = [
@@ -108,10 +109,7 @@ def gen_dp_overlays(
108
109
  ]
109
110
  # for each file type, check for required overlays
110
111
  for registry, registry_overlay in file_types:
111
- check_registry(ctx, ctx_overlay, overlay_dir, registry, registry_overlay)
112
-
113
- # add current overlays to pack
114
- ctx.data.overlays.merge(ctx_overlay.data.overlays)
112
+ check_registry(ctx, overlay_dir, registry, registry_overlay)
115
113
 
116
114
  # get pack.mcmeta overlay entries
117
115
  mcmeta: dict[str, dict[str, list[dict[str, Any]]]] = ctx.data.mcmeta.data.copy()
@@ -147,6 +145,11 @@ def gen_dp_overlays(
147
145
  }
148
146
  )
149
147
 
148
+ # add current overlays to pack
149
+ ctx.data.overlays.merge(ctx_overlay.data.overlays)
150
+ if "overlays" in ctx_overlay.data.mcmeta.data:
151
+ entries.extend(ctx_overlay.data.mcmeta.data["overlays"]["entries"])
152
+
150
153
  # save overlay entries in pack.mcmeta
151
154
  if len(entries) > 0:
152
155
  ctx.data.mcmeta.data.update({"overlays": {"entries": entries}})
@@ -154,7 +157,6 @@ def gen_dp_overlays(
154
157
 
155
158
  def check_registry(
156
159
  ctx: Context,
157
- ctx_overlay: Context,
158
160
  overlay_dir: str,
159
161
  registry: NamespaceProxy[Any],
160
162
  registry_overlay: NamespaceProxy[Any],
@@ -162,12 +164,11 @@ def check_registry(
162
164
  """
163
165
  Generates overlays for each namespace proxy.
164
166
 
165
- Keyword arguments:</br>
166
- `ctx` -- the build context</br>
167
- `ctx_overlay` -- the overlay context</br>
168
- `overlay_dir` -- the directory of the overlay</br>
169
- `registry` -- the namespace proxy from the build context</br>
170
- `registry_overlay` -- the namespace proxy from the overlay context</br>
167
+ Keyword arguments: \n
168
+ `ctx` -- the build context \n
169
+ `overlay_dir` -- the directory of the overlay \n
170
+ `registry` -- the namespace proxy from the build context \n
171
+ `registry_overlay` -- the namespace proxy from the overlay context \n
171
172
  """
172
173
  # check each file in the build pack
173
174
  for name in list(registry):
@@ -196,15 +197,15 @@ def gen_registry_overlay(
196
197
  type: str = "",
197
198
  ) -> None:
198
199
  """
199
- Checks if two functions have the same contents and generate an overlay if they don't.
200
-
201
- Keyword arguments:</br>
202
- `ctx` -- the build context</br>
203
- `overlay_dir` -- the directory of the generated overlay</br>
204
- `name` -- the name of the file</br>
205
- `registry` -- the namespace proxy from the build context</br>
206
- `registry_overlay` -- the namespace proxy from the overlay context</br>
207
- `type` -- either "deletion" or "addition" (default: `""`)</br>
200
+ Checks if two files have the same contents and generate an overlay if they don't.
201
+
202
+ Keyword arguments: \n
203
+ `ctx` -- the build context \n
204
+ `overlay_dir` -- the directory of the generated overlay \n
205
+ `name` -- the name of the file \n
206
+ `registry` -- the namespace proxy from the build context \n
207
+ `registry_overlay` -- the namespace proxy from the overlay context \n
208
+ `type`(optional) -- either "deletion" or "addition" (default: `""`) \n
208
209
  """
209
210
  if type == "deletion":
210
211
  # move file from build pack to overlay in build pack
@@ -1,14 +1,14 @@
1
1
  from beet import Context, run_beet
2
2
 
3
- from .data_pack import *
4
- from .resource_pack import *
3
+ from .data_pack import gen_dp_overlays
4
+ from .resource_pack import gen_rp_overlays
5
5
 
6
6
 
7
7
  def beet_default(ctx: Context):
8
8
  if "observer" not in ctx.meta:
9
9
  return
10
10
 
11
- # # check cache
11
+ # check cache
12
12
  cache = ctx.cache["observer"]
13
13
  cached_dp = False
14
14
  cached_rp = False
@@ -45,9 +45,12 @@ def beet_default(ctx: Context):
45
45
  "rp"
46
46
  ]
47
47
  # save current overlays
48
- save: list[str] = []
48
+ save_dp: list[str] = []
49
+ save_rp: list[str] = []
49
50
  for overlay in ctx.data.overlays:
50
- save.append(overlay)
51
+ save_dp.append(overlay)
52
+ for overlay in ctx.assets.overlays:
53
+ save_rp.append(overlay)
51
54
  # loop through all overlays
52
55
  for overlay in ctx.meta["observer"]["overlays"]:
53
56
  # get pack
@@ -67,9 +70,9 @@ def beet_default(ctx: Context):
67
70
  rp_dir = overlay["directory"]
68
71
  # compare build pack and overlay pack
69
72
  if not cached_dp and ctx.data:
70
- gen_dp_overlays(ctx, ctx_overlay, dp_dir, save)
73
+ gen_dp_overlays(ctx, ctx_overlay, dp_dir, save_dp)
71
74
  if not cached_rp and ctx.assets:
72
- gen_rp_overlays(ctx, ctx_overlay, rp_dir, save)
75
+ gen_rp_overlays(ctx, ctx_overlay, rp_dir, save_rp)
73
76
 
74
77
  # save to cache
75
78
  if not cached_dp and ctx.data:
@@ -9,10 +9,11 @@ def gen_rp_overlays(
9
9
  """
10
10
  Generates overlays between two resource packs.
11
11
 
12
- Keyword arguments:</br>
13
- `ctx` -- the build context</br>
14
- `ctx_overlay` -- the overlay context</br>
15
- `overlay_dir` -- the directory of the overlay</br>
12
+ Keyword arguments: \n
13
+ `ctx` -- the build context \n
14
+ `ctx_overlay` -- the overlay context \n
15
+ `overlay_dir` -- the directory of the overlay \n
16
+ `ignore` -- a list of overlays to ignore (existing overlays that should not be touched) \n
16
17
  """
17
18
  # create list of all resource pack file types
18
19
  file_types: list[tuple[NamespaceProxy[Any], NamespaceProxy[Any]]] = [
@@ -36,10 +37,7 @@ def gen_rp_overlays(
36
37
  ]
37
38
  # for each file type, check for required overlays
38
39
  for registry, registry_overlay in file_types:
39
- check_registry(ctx, ctx_overlay, overlay_dir, registry, registry_overlay)
40
-
41
- # add current overlays to pack
42
- ctx.assets.overlays.merge(ctx_overlay.assets.overlays)
40
+ check_registry(ctx, overlay_dir, registry, registry_overlay)
43
41
 
44
42
  # get pack.mcmeta overlay entries
45
43
  mcmeta: dict[str, dict[str, list[dict[str, Any]]]] = ctx.assets.mcmeta.data.copy()
@@ -75,6 +73,11 @@ def gen_rp_overlays(
75
73
  }
76
74
  )
77
75
 
76
+ # add current overlays to pack
77
+ ctx.assets.overlays.merge(ctx_overlay.assets.overlays)
78
+ if "overlays" in ctx_overlay.assets.mcmeta.data:
79
+ entries.extend(ctx_overlay.assets.mcmeta.data["overlays"]["entries"])
80
+
78
81
  # save overlay entries in pack.mcmeta
79
82
  if len(entries) > 0:
80
83
  ctx.assets.mcmeta.data.update({"overlays": {"entries": entries}})
@@ -82,7 +85,6 @@ def gen_rp_overlays(
82
85
 
83
86
  def check_registry(
84
87
  ctx: Context,
85
- ctx_overlay: Context,
86
88
  overlay_dir: str,
87
89
  registry: NamespaceProxy[Any],
88
90
  registry_overlay: NamespaceProxy[Any],
@@ -90,12 +92,11 @@ def check_registry(
90
92
  """
91
93
  Generates overlays for each namespace proxy.
92
94
 
93
- Keyword arguments:</br>
94
- `ctx` -- the build context</br>
95
- `ctx_overlay` -- the overlay context</br>
96
- `overlay_dir` -- the directory of the overlay</br>
97
- `registry` -- the namespace proxy from the build context</br>
98
- `registry_overlay` -- the namespace proxy from the overlay context</br>
95
+ Keyword arguments: \n
96
+ `ctx` -- the build context \n
97
+ `overlay_dir` -- the directory of the overlay \n
98
+ `registry` -- the namespace proxy from the build context \n
99
+ `registry_overlay` -- the namespace proxy from the overlay context \n
99
100
  """
100
101
  # check each file in the build pack
101
102
  for name in list(registry):
@@ -124,15 +125,15 @@ def gen_registry_overlay(
124
125
  type: str = "",
125
126
  ) -> None:
126
127
  """
127
- Checks if two functions have the same contents and generate an overlay if they don't.
128
-
129
- Keyword arguments:</br>
130
- `ctx` -- the build context</br>
131
- `overlay_dir` -- the directory of the generated overlay</br>
132
- `name` -- the name of the file</br>
133
- `registry` -- the namespace proxy from the build context</br>
134
- `registry_overlay` -- the namespace proxy from the overlay context</br>
135
- `type` -- either "deletion" or "addition" (default: `""`)</br>
128
+ Checks if two files have the same contents and generate an overlay if they don't.
129
+
130
+ Keyword arguments: \n
131
+ `ctx` -- the build context \n
132
+ `overlay_dir` -- the directory of the generated overlay \n
133
+ `name` -- the name of the file \n
134
+ `registry` -- the namespace proxy from the build context \n
135
+ `registry_overlay` -- the namespace proxy from the overlay context \n
136
+ `type`(optional) -- either "deletion" or "addition" (default: `""`) \n
136
137
  """
137
138
  if type == "deletion":
138
139
  # move file from build pack to overlay in build pack
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "beet-observer"
3
- version = "0.7.0"
3
+ version = "0.7.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"
@@ -36,8 +36,8 @@ profile = "black"
36
36
  typeCheckingMode = "strict"
37
37
 
38
38
  [tool.poe.tasks]
39
- format = {shell = "isort beet_observer & black beet_observer"}
40
- check = {shell = "isort --check-only beet_observer & black --check beet_observer"}
39
+ format = {shell = "isort beet_observer & black beet_observer & pyright"}
40
+ check = {shell = "isort --check-only beet_observer & black --check beet_observer & pyright"}
41
41
  typing = {shell = "pyright"}
42
42
 
43
43
  [build-system]
File without changes
File without changes