dfpyre 0.7.0__tar.gz → 0.7.2__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dfpyre
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: A package for creating and modifying code templates for the DiamondFire Minecraft server.
5
5
  Home-page: https://github.com/Amp63/pyre
6
6
  License: MIT
@@ -15,7 +15,7 @@ CODEBLOCK_NAME_LOOKUP = {
15
15
  'IF GAME': 'if_game',
16
16
  'IF VARIABLE': 'if_var',
17
17
  'REPEAT': 'repeat',
18
- 'SELECT OBJECT': 'select_object',
18
+ 'SELECT OBJECT': 'select_obj',
19
19
  'CONTROL': 'control',
20
20
  'PLAYER EVENT': 'event',
21
21
  'ENTITY EVENT': 'entity_event',
@@ -59,6 +59,11 @@ def parse_actiondump():
59
59
 
60
60
  codeblock_name = CODEBLOCK_NAME_LOOKUP[action_data['codeblockName']]
61
61
  codeblock_data[codeblock_name][action_data['name']] = parsed_action_data
62
+ if aliases := action_data['aliases']:
63
+ alias_data = parsed_action_data.copy()
64
+ alias_data['alias'] = action_data['name']
65
+ for alias in aliases:
66
+ codeblock_data[codeblock_name][alias] = alias_data
62
67
 
63
68
  return codeblock_data
64
69
 
@@ -363,10 +363,10 @@ def item_from_dict(item_dict: dict) -> object:
363
363
  note = _some_or(item_data.get('note'), '')
364
364
  param_type = ParameterType(PARAMETER_TYPE_LOOKUP.index(item_data['type']))
365
365
  if item_data['optional']:
366
- param = parameter(item_data['name'], param_type, item_data['plural'], True, description, note, item_from_dict(item_data['default_value']))
367
- else:
368
- param = parameter(item_data['name'], param_type, item_data['plural'], False, description, note)
369
- return param
366
+ if 'default_value' in item_data:
367
+ return parameter(item_data['name'], param_type, item_data['plural'], True, description, note, item_from_dict(item_data['default_value']))
368
+ return parameter(item_data['name'], param_type, item_data['plural'], True, description, note)
369
+ return parameter(item_data['name'], param_type, item_data['plural'], False, description, note)
370
370
  elif item_id in {'bl_tag', 'hint'}:
371
371
  return
372
372
  else:
@@ -19,7 +19,7 @@ from dfpyre.actiondump import CODEBLOCK_DATA, get_default_tags
19
19
 
20
20
  VARIABLE_TYPES = {'txt', 'comp', 'num', 'item', 'loc', 'var', 'snd', 'part', 'pot', 'g_val', 'vec', 'pn_el'}
21
21
  TEMPLATE_STARTERS = {'event', 'entity_event', 'func', 'process'}
22
- SINGLE_NAME_CODEBLOCKS = {'func', 'process', 'call_func', 'start_process', 'else'}
22
+ DYNAMIC_CODEBLOCKS = {'func', 'process', 'call_func', 'start_process'}
23
23
 
24
24
  TARGETS = ['Selection', 'Default', 'Killer', 'Damager', 'Shooter', 'Victim', 'AllPlayers', 'Projectile', 'AllEntities', 'AllMobs', 'LastEntity']
25
25
  TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
@@ -55,7 +55,7 @@ class CodeBlock:
55
55
  self.tags = tags
56
56
 
57
57
  def __repr__(self) -> str:
58
- if self.name in SINGLE_NAME_CODEBLOCKS:
58
+ if self.name in DYNAMIC_CODEBLOCKS:
59
59
  if self.name == 'else':
60
60
  return 'CodeBlock(else)'
61
61
  return f'CodeBlock({self.name}, {self.data["data"]})'
@@ -78,7 +78,7 @@ class CodeBlock:
78
78
  final_args = [arg.format(slot) for slot, arg in enumerate(self.args) if arg.type in VARIABLE_TYPES]
79
79
 
80
80
  # check for unrecognized name, add tags
81
- if codeblock_type is not None: # for brackets
81
+ if codeblock_type is not None and codeblock_type != 'else':
82
82
  if self.name not in CODEBLOCK_DATA[codeblock_type]:
83
83
  _warn_unrecognized_name(codeblock_type, self.name)
84
84
  elif include_tags:
@@ -227,16 +227,18 @@ class DFTemplate:
227
227
  args.append(parsed_item)
228
228
  target = Target(TARGETS.index(block_dict['target'])) if 'target' in block_dict else DEFAULT_TARGET
229
229
 
230
- codeblock_name = 'bracket'
231
- if 'block' in block_dict and block_dict['block'] in SINGLE_NAME_CODEBLOCKS:
232
- codeblock_name = block_dict['block']
230
+ codeblock_action = 'bracket'
231
+ if block_dict.get('block') == 'else':
232
+ codeblock_action = 'else'
233
+ elif block_dict.get('block') in DYNAMIC_CODEBLOCKS:
234
+ codeblock_action = 'dynamic'
233
235
  elif 'action' in block_dict:
234
- codeblock_name = block_dict['action']
236
+ codeblock_action = block_dict['action']
235
237
 
236
- if codeblock_name == 'bracket' or block_dict['block'] == 'else':
237
- codeblock = CodeBlock(codeblock_name, data=block_dict)
238
+ if codeblock_action == 'bracket' or block_dict['block'] == 'else':
239
+ codeblock = CodeBlock(codeblock_action, data=block_dict)
238
240
  else:
239
- codeblock = CodeBlock(codeblock_name, args, target, block_dict, tags=block_tags)
241
+ codeblock = CodeBlock(codeblock_action, args, target, block_dict, tags=block_tags)
240
242
  template.codeblocks.append(codeblock)
241
243
 
242
244
  return template
@@ -29,7 +29,6 @@ TEMPLATE_METHOD_LOOKUP = {
29
29
  }
30
30
 
31
31
  TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
32
- SINGLE_NAME_CODEBLOCKS = {'func', 'process', 'call_func', 'start_process'}
33
32
  VAR_SCOPES = {'unsaved': 'g', 'saved': 's', 'local': 'l', 'line': 'i'}
34
33
 
35
34
 
@@ -134,7 +133,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
134
133
 
135
134
  method_name = TEMPLATE_METHOD_LOOKUP[codeblock.data['block']]
136
135
  method_args = [f'"{codeblock.name}"']
137
- if codeblock.name in SINGLE_NAME_CODEBLOCKS:
136
+ if codeblock.name == 'dynamic':
138
137
  method_args[0] = f'"{codeblock.data["data"]}"'
139
138
 
140
139
  codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
@@ -143,7 +142,6 @@ def generate_script(template, flags: GeneratorFlags) -> str:
143
142
  if method_name in TARGET_CODEBLOCKS and codeblock.target.name != 'SELECTION':
144
143
  method_args.append(f'target=Target.{codeblock.target.name}')
145
144
  if codeblock.tags:
146
- print(codeblock.tags)
147
145
  default_tags = get_default_tags(codeblock.data.get('block'), codeblock.name)
148
146
  written_tags = {t: o for t, o in codeblock.tags.items() if default_tags[t] != o}
149
147
  if written_tags:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dfpyre"
3
- version = "0.7.0"
3
+ version = "0.7.2"
4
4
  description = "A package for creating and modifying code templates for the DiamondFire Minecraft server."
5
5
  authors = ["Amp"]
6
6
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes