dfpyre 0.8.17__tar.gz → 0.8.18__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.8.17
3
+ Version: 0.8.18
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
@@ -49,9 +49,11 @@ def item_to_string(class_name: str, i: Item, slot_argument: str):
49
49
  stripped_id = i.get_id().replace('minecraft:', '')
50
50
  if set(i.nbt.keys()) == {'id', 'count'}:
51
51
  if i.get_count() == 1:
52
- return f'{class_name}("{stripped_id}"{slot_argument})'
53
- return f'{class_name}("{stripped_id}", {i.get_count()}{slot_argument})'
54
- return f'{class_name}.from_snbt("""{i.get_snbt()}""")'
52
+ return f"{class_name}('{stripped_id}'{slot_argument})"
53
+ return f"{class_name}('{stripped_id}', {i.get_count()}{slot_argument})"
54
+
55
+ snbt_string = i.get_snbt().replace('\\"', '\\\\"')
56
+ return f'{class_name}.from_snbt("""{snbt_string}""")'
55
57
 
56
58
 
57
59
  def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
@@ -65,16 +67,16 @@ def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
65
67
  if isinstance(arg_item, String):
66
68
  value = arg_item.value.replace('\n', '\\n')
67
69
  if not has_slot and flags.literal_shorthand:
68
- return f'"{value}"'
69
- return f'{class_name}("{value}"{slot_argument})'
70
+ return f"'{value}'"
71
+ return f"{class_name}('{value}'{slot_argument})"
70
72
 
71
73
  if isinstance(arg_item, Text):
72
74
  value = arg_item.value.replace('\n', '\\n')
73
- return f'{class_name}("{value}"{slot_argument})'
75
+ return f"{class_name}('{value}'{slot_argument})"
74
76
 
75
77
  if isinstance(arg_item, Number):
76
78
  if not is_number(str(arg_item.value)): # Probably a math expression
77
- return f'{class_name}("{arg_item.value}"{slot_argument})'
79
+ return f"{class_name}('{arg_item.value}'{slot_argument})"
78
80
  if not has_slot and flags.literal_shorthand:
79
81
  return str(arg_item.value)
80
82
  return f'{class_name}({arg_item.value}{slot_argument})'
@@ -89,28 +91,28 @@ def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
89
91
 
90
92
  if isinstance(arg_item, Variable):
91
93
  if not has_slot and flags.var_shorthand:
92
- return f'"${VAR_SCOPES[arg_item.scope]} {arg_item.name}"'
94
+ return f"'${VAR_SCOPES[arg_item.scope]} {arg_item.name}'"
93
95
  if arg_item.scope == 'unsaved':
94
- return f'{class_name}("{arg_item.name}"{slot_argument})'
95
- return f'{class_name}("{arg_item.name}", "{arg_item.scope}"{slot_argument})'
96
+ return f"{class_name}('{arg_item.name}'{slot_argument})"
97
+ return f"{class_name}('{arg_item.name}', '{arg_item.scope}'{slot_argument})"
96
98
 
97
99
  if isinstance(arg_item, Sound):
98
- return f'{class_name}("{arg_item.name}", {arg_item.pitch}, {arg_item.vol}{slot_argument})'
100
+ return f"{class_name}('{arg_item.name}', {arg_item.pitch}, {arg_item.vol}{slot_argument})"
99
101
 
100
102
  if isinstance(arg_item, Particle):
101
103
  return f'{class_name}({arg_item.particle_data})'
102
104
 
103
105
  if isinstance(arg_item, Potion):
104
- return f'{class_name}("{arg_item.name}", {arg_item.dur}, {arg_item.amp}{slot_argument})'
106
+ return f"{class_name}('{arg_item.name}', {arg_item.dur}, {arg_item.amp}{slot_argument})"
105
107
 
106
108
  if isinstance(arg_item, GameValue):
107
109
  if arg_item.target == 'Default':
108
- return f'{class_name}("{arg_item.name}"{slot_argument})'
109
- return f'{class_name}("{arg_item.name}", "{arg_item.target}"{slot_argument})'
110
+ return f"{class_name}('{arg_item.name}'{slot_argument})"
111
+ return f"{class_name}('{arg_item.name}', '{arg_item.target}'{slot_argument})"
110
112
 
111
113
  if isinstance(arg_item, Parameter):
112
114
  param_type_class_name = arg_item.param_type.__class__.__name__
113
- param_args = [f'"{arg_item.name}"', f'{param_type_class_name}.{arg_item.param_type.name}']
115
+ param_args = [f"'{arg_item.name}'", f'{param_type_class_name}.{arg_item.param_type.name}']
114
116
  if arg_item.plural:
115
117
  param_args.append('plural=True')
116
118
  if arg_item.optional:
@@ -118,9 +120,9 @@ def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
118
120
  if arg_item.default_value is not None:
119
121
  param_args.append(f'default_value={argument_item_to_string(flags, arg_item.default_value)}')
120
122
  if arg_item.description:
121
- param_args.append(f'description="{arg_item.description}"')
123
+ param_args.append(f"description='{arg_item.description}'")
122
124
  if arg_item.note:
123
- param_args.append(f'note="{arg_item.note}"')
125
+ param_args.append(f"note='{arg_item.note}'")
124
126
  return f'{class_name}({", ".join(param_args)}{slot_argument})'
125
127
 
126
128
  if isinstance(arg_item, Vector):
@@ -174,7 +176,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
174
176
 
175
177
  # Get codeblock function and start its arguments with the action
176
178
  function_name = TEMPLATE_FUNCTION_LOOKUP[codeblock.type]
177
- function_args = [f'"{codeblock.action_name}"']
179
+ function_args = [f"'{codeblock.action_name}'"]
178
180
 
179
181
  # Add variable assignment if necessary
180
182
  var_assignment_snippet = ''
@@ -184,7 +186,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
184
186
 
185
187
  # Set function or process name if necessary
186
188
  if codeblock.action_name == 'dynamic':
187
- function_args[0] = f'"{codeblock.data["data"]}"'
189
+ function_args[0] = f"'{codeblock.data["data"]}'"
188
190
 
189
191
  # Convert argument objects to valid Python strings
190
192
  codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
@@ -204,7 +206,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
204
206
 
205
207
  # Add sub-action for repeat
206
208
  if codeblock.data.get('subAction'):
207
- function_args.append(f'sub_action="{codeblock.data["subAction"]}"')
209
+ function_args.append(f"sub_action='{codeblock.data["subAction"]}'")
208
210
 
209
211
  # Add inversion for NOT
210
212
  if codeblock.data.get('attribute') == 'NOT':
@@ -215,7 +217,7 @@ def generate_script(template, flags: GeneratorFlags) -> str:
215
217
  if codeblock.type == 'else':
216
218
  line = f'{function_name}(['
217
219
  elif codeblock.type in {'event', 'entity_event'}:
218
- line = f'{function_name}({", ".join(function_args)}, [' # omit `codeblocks=` when we don't need it
220
+ line = f'{var_assignment_snippet}{function_name}({", ".join(function_args)}, [' # omit `codeblocks=` when we don't need it
219
221
  else:
220
222
  line = f'{var_assignment_snippet}{function_name}({", ".join(function_args)}, codeblocks=['
221
223
  add_script_line(flags, script_lines, indent_level, line, False)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dfpyre"
3
- version = "0.8.17"
3
+ version = "0.8.18"
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
File without changes