dfpyre 0.7.11__tar.gz → 0.7.12__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.11
3
+ Version: 0.7.12
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
@@ -111,10 +111,10 @@ def _warn_unrecognized_name(codeblock_type: str, codeblock_name: str):
111
111
 
112
112
  def _add_inverted(data, inverted):
113
113
  """
114
- If inverted is true, add 'inverted': 'NOT' to data.
114
+ If inverted is true, add 'attribute': 'NOT' to data.
115
115
  """
116
116
  if inverted:
117
- data['inverted'] = 'NOT'
117
+ data['attribute'] = 'NOT'
118
118
 
119
119
 
120
120
  def _convert_args(args):
@@ -3,6 +3,7 @@ import re
3
3
  from dfpyre.items import *
4
4
  from dfpyre.actiondump import get_default_tags
5
5
 
6
+
6
7
  SCRIPT_START = '''from dfpyre import *
7
8
 
8
9
  t = DFTemplate()
@@ -127,11 +128,11 @@ def add_script_line(flags: GeneratorFlags, script_lines: list[str], indent_level
127
128
  script_lines.append(added_line)
128
129
 
129
130
 
130
- # TODO: add tag values if not default
131
131
  def generate_script(template, flags: GeneratorFlags) -> str:
132
132
  indent_level = 0
133
133
  script_lines = []
134
134
  for codeblock in template.codeblocks:
135
+ # Handle brackets and indentation
135
136
  if codeblock.name == 'bracket':
136
137
  if codeblock.data['direct'] == 'open':
137
138
  add_script_line(flags, script_lines, indent_level, 't.bracket(', False)
@@ -140,26 +141,45 @@ def generate_script(template, flags: GeneratorFlags) -> str:
140
141
  indent_level -= 1
141
142
  add_script_line(flags, script_lines, indent_level, ')')
142
143
  continue
144
+
145
+ # Handle else
143
146
  if codeblock.name == 'else':
144
147
  add_script_line(flags, script_lines, indent_level, 't.else_()')
145
148
  continue
146
149
 
150
+
151
+ # Get codeblock method and start its arguments with the action
147
152
  method_name = TEMPLATE_METHOD_LOOKUP[codeblock.data['block']]
148
153
  method_args = [f'"{codeblock.name}"']
154
+
155
+ # Set function or process name if necessary
149
156
  if codeblock.name == 'dynamic':
150
157
  method_args[0] = f'"{codeblock.data["data"]}"'
151
158
 
159
+ # Convert argument objects to valid Python strings
152
160
  codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
153
161
  if codeblock_args:
154
162
  method_args.extend(codeblock_args)
163
+
164
+ # Add target if necessary
155
165
  if method_name in TARGET_CODEBLOCKS and codeblock.target.name != 'SELECTION':
156
166
  method_args.append(f'target=Target.{codeblock.target.name}')
167
+
168
+ # Add tags
157
169
  if codeblock.tags:
158
170
  default_tags = get_default_tags(codeblock.data.get('block'), codeblock.name)
159
171
  written_tags = {t: o for t, o in codeblock.tags.items() if default_tags[t] != o}
160
172
  if written_tags:
161
173
  method_args.append(f'tags={str(written_tags)}')
162
174
 
175
+ # Add sub-action for repeat
176
+ if codeblock.data.get('subAction'):
177
+ method_args.append(f'sub_action="{codeblock.data["subAction"]}"')
178
+
179
+ # Add inversion for NOT
180
+ if codeblock.data.get('attribute') == 'NOT':
181
+ method_args.append('inverted=True')
182
+
163
183
  line = f't.{method_name}({", ".join(method_args)})'
164
184
  add_script_line(flags, script_lines, indent_level, line)
165
185
  return SCRIPT_START + '\n'.join(script_lines)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dfpyre"
3
- version = "0.7.11"
3
+ version = "0.7.12"
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
File without changes
File without changes