beet-observer 0.7.0__py3-none-any.whl → 0.7.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- beet_observer/__init__.py +1 -1
- beet_observer/data_pack.py +25 -24
- beet_observer/plugin.py +10 -7
- beet_observer/resource_pack.py +25 -24
- {beet_observer-0.7.0.dist-info → beet_observer-0.7.2.dist-info}/METADATA +1 -1
- beet_observer-0.7.2.dist-info/RECORD +8 -0
- beet_observer-0.7.0.dist-info/RECORD +0 -8
- {beet_observer-0.7.0.dist-info → beet_observer-0.7.2.dist-info}/LICENSE +0 -0
- {beet_observer-0.7.0.dist-info → beet_observer-0.7.2.dist-info}/WHEEL +0 -0
beet_observer/__init__.py
CHANGED
beet_observer/data_pack.py
CHANGED
@@ -10,10 +10,11 @@ def gen_dp_overlays(
|
|
10
10
|
"""
|
11
11
|
Generates overlays between two datapacks.
|
12
12
|
|
13
|
-
Keyword arguments
|
14
|
-
`ctx` -- the build context
|
15
|
-
`ctx_overlay` -- the overlay context
|
16
|
-
`overlay_dir` -- the directory of the overlay
|
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,
|
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
|
166
|
-
`ctx` -- the build context
|
167
|
-
`
|
168
|
-
`
|
169
|
-
`
|
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
|
200
|
-
|
201
|
-
Keyword arguments
|
202
|
-
`ctx` -- the build context
|
203
|
-
`overlay_dir` -- the directory of the generated overlay
|
204
|
-
`name` -- the name of the file
|
205
|
-
`registry` -- the namespace proxy from the build context
|
206
|
-
`registry_overlay` -- the namespace proxy from the overlay context
|
207
|
-
`type` -- either "deletion" or "addition" (default: `""`)
|
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
|
beet_observer/plugin.py
CHANGED
@@ -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
|
-
#
|
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
|
-
|
48
|
+
save_dp: list[str] = []
|
49
|
+
save_rp: list[str] = []
|
49
50
|
for overlay in ctx.data.overlays:
|
50
|
-
|
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,
|
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,
|
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:
|
beet_observer/resource_pack.py
CHANGED
@@ -9,10 +9,11 @@ def gen_rp_overlays(
|
|
9
9
|
"""
|
10
10
|
Generates overlays between two resource packs.
|
11
11
|
|
12
|
-
Keyword arguments
|
13
|
-
`ctx` -- the build context
|
14
|
-
`ctx_overlay` -- the overlay context
|
15
|
-
`overlay_dir` -- the directory of the overlay
|
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,
|
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
|
94
|
-
`ctx` -- the build context
|
95
|
-
`
|
96
|
-
`
|
97
|
-
`
|
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
|
128
|
-
|
129
|
-
Keyword arguments
|
130
|
-
`ctx` -- the build context
|
131
|
-
`overlay_dir` -- the directory of the generated overlay
|
132
|
-
`name` -- the name of the file
|
133
|
-
`registry` -- the namespace proxy from the build context
|
134
|
-
`registry_overlay` -- the namespace proxy from the overlay context
|
135
|
-
`type` -- either "deletion" or "addition" (default: `""`)
|
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
|
@@ -0,0 +1,8 @@
|
|
1
|
+
beet_observer/__init__.py,sha256=JcF4rPyJxqAn0u-uUEv2tLL9azWoXI9PVD-uGE3sZnQ,45
|
2
|
+
beet_observer/data_pack.py,sha256=0qvnIwXlP_A_I1DAnvloW9ryaUZh2Qm1VF-Qux6IxBc,9973
|
3
|
+
beet_observer/plugin.py,sha256=NXLMkfsxxlnJbR51eM4TGOf1vCR30rNYSr6l4djqnT8,2973
|
4
|
+
beet_observer/resource_pack.py,sha256=hwFlwQiRUFg1V9Zy-U4gVUOvZxqEzyqHgoBdwzqoAXc,6211
|
5
|
+
beet_observer-0.7.2.dist-info/LICENSE,sha256=oBbP6j7sgG9darFSRZxV7iO8yPR1aZiDspSK3mcLpXI,1062
|
6
|
+
beet_observer-0.7.2.dist-info/METADATA,sha256=KleELV6Buct3KDzBcBamAMwVbKhEec4wSgs6UmewNBo,674
|
7
|
+
beet_observer-0.7.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
8
|
+
beet_observer-0.7.2.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
beet_observer/__init__.py,sha256=Y1gc4glC_mLy4ZYlXwD5eO0bATwzqnv2s7PuK_Rwnxc,45
|
2
|
-
beet_observer/data_pack.py,sha256=oTq2jRNer7bE9lGgva98ubZ5TTIF65cSkOUSBQNWIac,9845
|
3
|
-
beet_observer/plugin.py,sha256=mtGBtJNCiUHkSGiAoRl7li0oIlZBQ-cuDS91bubDaPs,2835
|
4
|
-
beet_observer/resource_pack.py,sha256=BtVu0sGO20vUwOOnBrQdXvVATv2iV3ubEc0LCB8DqfQ,6079
|
5
|
-
beet_observer-0.7.0.dist-info/LICENSE,sha256=oBbP6j7sgG9darFSRZxV7iO8yPR1aZiDspSK3mcLpXI,1062
|
6
|
-
beet_observer-0.7.0.dist-info/METADATA,sha256=p2qCjgtHHomeWkbvnQw0ZbGhKlPQdkERq6e8Ycai94c,674
|
7
|
-
beet_observer-0.7.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
8
|
-
beet_observer-0.7.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|