dfpyre 0.8.12__py3-none-any.whl → 0.8.14__py3-none-any.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 dfpyre might be problematic. Click here for more details.
- dfpyre/actiondump.py +5 -3
- dfpyre/items.py +26 -2
- dfpyre/pyre.py +11 -4
- {dfpyre-0.8.12.dist-info → dfpyre-0.8.14.dist-info}/METADATA +1 -1
- {dfpyre-0.8.12.dist-info → dfpyre-0.8.14.dist-info}/RECORD +7 -7
- {dfpyre-0.8.12.dist-info → dfpyre-0.8.14.dist-info}/LICENSE +0 -0
- {dfpyre-0.8.12.dist-info → dfpyre-0.8.14.dist-info}/WHEEL +0 -0
dfpyre/actiondump.py
CHANGED
|
@@ -52,20 +52,22 @@ def parse_actiondump() -> ActiondumpResult:
|
|
|
52
52
|
codeblock_data = {n: {} for n in CODEBLOCK_NAME_LOOKUP.values()}
|
|
53
53
|
codeblock_data['else'] = {'tags': []}
|
|
54
54
|
|
|
55
|
-
|
|
56
55
|
if not os.path.exists(ACTIONDUMP_PATH):
|
|
57
56
|
warn('data.json not found -- Item tags and error checking will not work.')
|
|
58
57
|
return {}, set()
|
|
59
58
|
|
|
60
59
|
with open(ACTIONDUMP_PATH, 'r', encoding='utf-8') as f:
|
|
61
60
|
actiondump = json.loads(f.read())
|
|
62
|
-
|
|
63
61
|
for action_data in actiondump['actions']:
|
|
64
62
|
action_tags = get_action_tags(action_data)
|
|
65
|
-
parsed_action_data = {'tags': action_tags}
|
|
63
|
+
parsed_action_data = {'tags': action_tags, 'required_rank': 'None'}
|
|
66
64
|
if dep_note := action_data['icon']['deprecatedNote']:
|
|
67
65
|
parsed_action_data['deprecatedNote'] = ' '.join(dep_note)
|
|
68
66
|
|
|
67
|
+
required_rank = action_data['icon']['requiredRank']
|
|
68
|
+
if required_rank:
|
|
69
|
+
parsed_action_data['required_rank'] = required_rank
|
|
70
|
+
|
|
69
71
|
codeblock_name = CODEBLOCK_NAME_LOOKUP[action_data['codeblockName']]
|
|
70
72
|
codeblock_data[codeblock_name][action_data['name']] = parsed_action_data
|
|
71
73
|
if aliases := action_data['aliases']:
|
dfpyre/items.py
CHANGED
|
@@ -454,6 +454,25 @@ class Parameter:
|
|
|
454
454
|
return f'{self.__class__.__name__}({self.name}, type: {raw_type})'
|
|
455
455
|
|
|
456
456
|
|
|
457
|
+
class _Tag:
|
|
458
|
+
"""
|
|
459
|
+
Represents a CodeBlock action tag.
|
|
460
|
+
"""
|
|
461
|
+
type = 'bl_tag'
|
|
462
|
+
|
|
463
|
+
def __init__(self, tag_data: dict, slot: int | None=None):
|
|
464
|
+
self.tag_data = tag_data
|
|
465
|
+
self.slot = slot
|
|
466
|
+
|
|
467
|
+
def format(self, slot: int|None):
|
|
468
|
+
formatted_dict = {"item": {"id": self.type, "data": self.tag_data}}
|
|
469
|
+
_add_slot(formatted_dict, self.slot or slot)
|
|
470
|
+
return formatted_dict
|
|
471
|
+
|
|
472
|
+
def __repr__(self) -> str:
|
|
473
|
+
return f'{self.__class__.__name__}({self.tag_data})'
|
|
474
|
+
|
|
475
|
+
|
|
457
476
|
def item_from_dict(item_dict: dict, preserve_item_slots: bool) -> Any:
|
|
458
477
|
item_id = item_dict['item']['id']
|
|
459
478
|
item_data = item_dict['item']['data']
|
|
@@ -507,12 +526,17 @@ def item_from_dict(item_dict: dict, preserve_item_slots: bool) -> Any:
|
|
|
507
526
|
param_type = ParameterType(PARAMETER_TYPE_LOOKUP.index(item_data['type']))
|
|
508
527
|
if item_data['optional']:
|
|
509
528
|
if 'default_value' in item_data:
|
|
510
|
-
|
|
529
|
+
default_value_dict = {'item': item_data['default_value'], 'slot': None}
|
|
530
|
+
default_value_item = item_from_dict(default_value_dict, preserve_item_slots)
|
|
511
531
|
return Parameter(item_data['name'], param_type, item_data['plural'], True, description, note, default_value_item, item_slot)
|
|
512
532
|
return Parameter(item_data['name'], param_type, item_data['plural'], True, description, note, slot=item_slot)
|
|
513
533
|
return Parameter(item_data['name'], param_type, item_data['plural'], False, description, note, slot=item_slot)
|
|
514
534
|
|
|
515
|
-
elif item_id
|
|
535
|
+
elif item_id == 'bl_tag':
|
|
536
|
+
if 'variable' in item_data:
|
|
537
|
+
return _Tag(item_data, item_slot)
|
|
538
|
+
|
|
539
|
+
elif item_id == 'hint': # Ignore hints
|
|
516
540
|
return
|
|
517
541
|
|
|
518
542
|
else:
|
dfpyre/pyre.py
CHANGED
|
@@ -16,7 +16,7 @@ from dfpyre.actiondump import CODEBLOCK_DATA, get_default_tags
|
|
|
16
16
|
from dfpyre.action_literals import *
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
VARIABLE_TYPES = {'txt', 'comp', 'num', 'item', 'loc', 'var', 'snd', 'part', 'pot', 'g_val', 'vec', 'pn_el'}
|
|
19
|
+
VARIABLE_TYPES = {'txt', 'comp', 'num', 'item', 'loc', 'var', 'snd', 'part', 'pot', 'g_val', 'vec', 'pn_el', 'bl_tag'}
|
|
20
20
|
TEMPLATE_STARTERS = {'event', 'entity_event', 'func', 'process'}
|
|
21
21
|
DYNAMIC_CODEBLOCKS = {'func', 'process', 'call_func', 'start_process'}
|
|
22
22
|
|
|
@@ -118,13 +118,20 @@ class CodeBlock:
|
|
|
118
118
|
|
|
119
119
|
# add items into args
|
|
120
120
|
final_args = [arg.format(slot) for slot, arg in enumerate(self.args) if arg.type in VARIABLE_TYPES]
|
|
121
|
+
already_applied_tags: dict[str, dict] = {a['item']['data']['tag']: a for a in final_args if a['item']['id'] == 'bl_tag'}
|
|
121
122
|
|
|
122
123
|
# check for unrecognized name, add tags
|
|
123
124
|
if self.type not in {'bracket', 'else'}:
|
|
124
125
|
if self.action_name not in CODEBLOCK_DATA[self.type]:
|
|
125
126
|
_warn_unrecognized_name(self.type, self.action_name)
|
|
127
|
+
|
|
126
128
|
elif include_tags:
|
|
127
129
|
tags = _get_codeblock_tags(self.type, self.action_name, self.tags)
|
|
130
|
+
for i, tag_data in enumerate(tags):
|
|
131
|
+
already_applied_tag_data = already_applied_tags.get(tag_data['item']['data']['tag'])
|
|
132
|
+
if already_applied_tag_data is not None:
|
|
133
|
+
tags[i] = already_applied_tag_data
|
|
134
|
+
|
|
128
135
|
if len(final_args) + len(tags) > 27:
|
|
129
136
|
final_args = final_args[:(27-len(tags))] # trim list if over 27 elements
|
|
130
137
|
final_args.extend(tags) # add tags to end
|
|
@@ -160,7 +167,7 @@ def _check_applied_tags(tags: list[dict], applied_tags: dict[str, str], codebloc
|
|
|
160
167
|
return valid_tags
|
|
161
168
|
|
|
162
169
|
|
|
163
|
-
def _reformat_codeblock_tags(tags: list[dict], codeblock_type: str, codeblock_action: str, applied_tags: dict[str, str]):
|
|
170
|
+
def _reformat_codeblock_tags(tags: list[dict], codeblock_type: str, codeblock_action: str, applied_tags: dict[str, str]) -> list[dict]:
|
|
164
171
|
"""
|
|
165
172
|
Turns tag objects into DiamondFire formatted tag items.
|
|
166
173
|
"""
|
|
@@ -187,7 +194,7 @@ def _reformat_codeblock_tags(tags: list[dict], codeblock_type: str, codeblock_ac
|
|
|
187
194
|
return reformatted_tags
|
|
188
195
|
|
|
189
196
|
|
|
190
|
-
def _get_codeblock_tags(codeblock_type: str, codeblock_name: str, applied_tags: dict[str, str]):
|
|
197
|
+
def _get_codeblock_tags(codeblock_type: str, codeblock_name: str, applied_tags: dict[str, str]) -> list[dict]:
|
|
191
198
|
"""
|
|
192
199
|
Get tags for the specified codeblock type and name.
|
|
193
200
|
"""
|
|
@@ -244,7 +251,7 @@ class DFTemplate:
|
|
|
244
251
|
|
|
245
252
|
|
|
246
253
|
@staticmethod
|
|
247
|
-
def from_code(template_code: str, preserve_item_slots: bool=
|
|
254
|
+
def from_code(template_code: str, preserve_item_slots: bool=True):
|
|
248
255
|
"""
|
|
249
256
|
Create a template object from an existing template code.
|
|
250
257
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
dfpyre/__init__.py,sha256=apPsSxJ1Tztfl71MoORoSmDfX7LyKLYlLwOGeLQUitw,25
|
|
2
2
|
dfpyre/action_literals.py,sha256=bwdLVDi2sU_4HUmvyOJtCguPOWJga_fQTPLtzPm4Mr4,52084
|
|
3
|
-
dfpyre/actiondump.py,sha256=
|
|
3
|
+
dfpyre/actiondump.py,sha256=FiL6Bit39djj_7NJo3vDZwOvVzv8pax4fRejL6isqnU,3579
|
|
4
4
|
dfpyre/data/actiondump_min.json,sha256=a7Wvc_qBuzv-C_puidQ0vq7pYeM1oojeAimYpVykP_o,2478020
|
|
5
|
-
dfpyre/items.py,sha256=
|
|
6
|
-
dfpyre/pyre.py,sha256
|
|
5
|
+
dfpyre/items.py,sha256=GOUogkwm7TzgC4AmRem623BtGggxtFcgD2uTporNDgs,17409
|
|
6
|
+
dfpyre/pyre.py,sha256=iP7D8Bt36vRZp_gd_M7IgViWYHzSDdh2fT_sDLrAMso,25454
|
|
7
7
|
dfpyre/scriptgen.py,sha256=uCG32PlOdcJJBBKn91458eMgP_Ml4K4-n2Fk3LN0T4g,8054
|
|
8
8
|
dfpyre/style.py,sha256=mLW1CFvvi8_9fk8JaH10I5S4WI0YBdQIXHtI3G_4sR8,980
|
|
9
9
|
dfpyre/util.py,sha256=Jt-gJjbBWvv2Q2HFxU09OUeLje2OZbB3nAvs87IuHqQ,807
|
|
10
|
-
dfpyre-0.8.
|
|
11
|
-
dfpyre-0.8.
|
|
12
|
-
dfpyre-0.8.
|
|
13
|
-
dfpyre-0.8.
|
|
10
|
+
dfpyre-0.8.14.dist-info/LICENSE,sha256=_vuDskB0ja2c-Fgm7Gt8Q8cO9NsLNpZAVyvmZwX7E6o,1060
|
|
11
|
+
dfpyre-0.8.14.dist-info/METADATA,sha256=qVBDbQiYa4dkAProrhYeheVM25z9ImYsu47g9-l6HHE,11949
|
|
12
|
+
dfpyre-0.8.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
13
|
+
dfpyre-0.8.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|