dfpyre 0.7.10__py3-none-any.whl → 0.7.11__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 +77 -77
- dfpyre/items.py +372 -372
- dfpyre/pyre.py +457 -457
- dfpyre/scriptgen.py +165 -165
- dfpyre/style.py +21 -21
- dfpyre/util.py +28 -28
- {dfpyre-0.7.10.dist-info → dfpyre-0.7.11.dist-info}/LICENSE +21 -21
- {dfpyre-0.7.10.dist-info → dfpyre-0.7.11.dist-info}/METADATA +2 -2
- dfpyre-0.7.11.dist-info/RECORD +12 -0
- dfpyre-0.7.10.dist-info/RECORD +0 -12
- {dfpyre-0.7.10.dist-info → dfpyre-0.7.11.dist-info}/WHEEL +0 -0
dfpyre/scriptgen.py
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
import dataclasses
|
|
2
|
-
import re
|
|
3
|
-
from dfpyre.items import *
|
|
4
|
-
from dfpyre.actiondump import get_default_tags
|
|
5
|
-
|
|
6
|
-
SCRIPT_START = '''from dfpyre import *
|
|
7
|
-
|
|
8
|
-
t = DFTemplate()
|
|
9
|
-
'''
|
|
10
|
-
|
|
11
|
-
TEMPLATE_METHOD_LOOKUP = {
|
|
12
|
-
'event': 'player_event',
|
|
13
|
-
'entity_event': 'entity_event',
|
|
14
|
-
'func': 'function',
|
|
15
|
-
'process': 'process',
|
|
16
|
-
'call_func': 'call_function',
|
|
17
|
-
'start_process': 'start_process',
|
|
18
|
-
'player_action': 'player_action',
|
|
19
|
-
'game_action': 'game_action',
|
|
20
|
-
'entity_action': 'entity_action',
|
|
21
|
-
'if_player': 'if_player',
|
|
22
|
-
'if_var': 'if_variable',
|
|
23
|
-
'if_game': 'if_game',
|
|
24
|
-
'if_entity': 'if_entity',
|
|
25
|
-
'else': 'else_',
|
|
26
|
-
'repeat': 'repeat',
|
|
27
|
-
'control': 'control',
|
|
28
|
-
'select_obj': 'select_object',
|
|
29
|
-
'set_var': 'set_variable'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
|
|
33
|
-
VAR_SCOPES = {'unsaved': 'g', 'saved': 's', 'local': 'l', 'line': 'i'}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@dataclasses.dataclass
|
|
37
|
-
class GeneratorFlags:
|
|
38
|
-
indent_size: int
|
|
39
|
-
literal_shorthand: bool
|
|
40
|
-
var_shorthand: bool
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def item_to_string(class_name: str, i: item):
|
|
44
|
-
i.nbt.data.pop('~DF_NBT', None)
|
|
45
|
-
stripped_id = i.get_id().replace('minecraft:', '')
|
|
46
|
-
if i.nbt.key_set() == {'~id', '~count'}:
|
|
47
|
-
if i.get_count() == 1:
|
|
48
|
-
return f'{class_name}("{stripped_id}")'
|
|
49
|
-
return f'{class_name}("{stripped_id}", {i.get_count()})'
|
|
50
|
-
return f'{class_name}.from_nbt("""{i.get_nbt()}""")'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
|
|
54
|
-
class_name = arg_item.__class__.__name__
|
|
55
|
-
if isinstance(arg_item, item):
|
|
56
|
-
return item_to_string(class_name, arg_item)
|
|
57
|
-
|
|
58
|
-
if isinstance(arg_item, string):
|
|
59
|
-
value = arg_item.value.replace('\n', '\\n')
|
|
60
|
-
return f'{class_name}("{value}")'
|
|
61
|
-
|
|
62
|
-
if isinstance(arg_item, text):
|
|
63
|
-
value = arg_item.value.replace('\n', '\\n')
|
|
64
|
-
if flags.literal_shorthand:
|
|
65
|
-
return f'"{value}"'
|
|
66
|
-
return f'{class_name}("{value}")'
|
|
67
|
-
|
|
68
|
-
if isinstance(arg_item, num):
|
|
69
|
-
if not re.match(NUMBER_REGEX, str(arg_item.value)):
|
|
70
|
-
return f'{class_name}("{arg_item.value}")'
|
|
71
|
-
if flags.literal_shorthand:
|
|
72
|
-
return str(arg_item.value)
|
|
73
|
-
return f'{class_name}({arg_item.value})'
|
|
74
|
-
|
|
75
|
-
if isinstance(arg_item, loc):
|
|
76
|
-
loc_components = [arg_item.x, arg_item.y, arg_item.z]
|
|
77
|
-
if arg_item.pitch != 0:
|
|
78
|
-
loc_components.append(arg_item.pitch)
|
|
79
|
-
if arg_item.yaw != 0:
|
|
80
|
-
loc_components.append(arg_item.yaw)
|
|
81
|
-
return f'{class_name}({", ".join(str(c) for c in loc_components)})'
|
|
82
|
-
|
|
83
|
-
if isinstance(arg_item, var):
|
|
84
|
-
if flags.var_shorthand:
|
|
85
|
-
return f'"${VAR_SCOPES[arg_item.scope]}{arg_item.name}"'
|
|
86
|
-
if arg_item.scope == 'unsaved':
|
|
87
|
-
return f'{class_name}("{arg_item.name}")'
|
|
88
|
-
return f'{class_name}("{arg_item.name}", "{arg_item.scope}")'
|
|
89
|
-
|
|
90
|
-
if isinstance(arg_item, sound):
|
|
91
|
-
return f'{class_name}("{arg_item.name}", {arg_item.pitch}, {arg_item.vol})'
|
|
92
|
-
|
|
93
|
-
if isinstance(arg_item, particle):
|
|
94
|
-
return f'{class_name}({arg_item.particle_data})'
|
|
95
|
-
|
|
96
|
-
if isinstance(arg_item, potion):
|
|
97
|
-
return f'{class_name}("{arg_item.name}", {arg_item.dur}, {arg_item.amp})'
|
|
98
|
-
|
|
99
|
-
if isinstance(arg_item, gamevalue):
|
|
100
|
-
if arg_item.target == 'Default':
|
|
101
|
-
return f'{class_name}("{arg_item.name}")'
|
|
102
|
-
return f'{class_name}("{arg_item.name}", "{arg_item.target}")'
|
|
103
|
-
|
|
104
|
-
if isinstance(arg_item, parameter):
|
|
105
|
-
param_type_class_name = arg_item.param_type.__class__.__name__
|
|
106
|
-
param_args = [f'"{arg_item.name}"', f'{param_type_class_name}.{arg_item.param_type.name}']
|
|
107
|
-
if arg_item.plural:
|
|
108
|
-
param_args.append('plural=True')
|
|
109
|
-
if arg_item.optional:
|
|
110
|
-
param_args.append('optional=True')
|
|
111
|
-
if arg_item.default_value is not None:
|
|
112
|
-
param_args.append(f'default_value={argument_item_to_string(flags, arg_item.default_value)}')
|
|
113
|
-
if arg_item.description:
|
|
114
|
-
param_args.append(f'description="{arg_item.description}"')
|
|
115
|
-
if arg_item.note:
|
|
116
|
-
param_args.append(f'note="{arg_item.note}"')
|
|
117
|
-
return f'{class_name}({", ".join(param_args)})'
|
|
118
|
-
|
|
119
|
-
if isinstance(arg_item, vector):
|
|
120
|
-
return f'{class_name}({arg_item.x}, {arg_item.y}, {arg_item.z})'
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def add_script_line(flags: GeneratorFlags, script_lines: list[str], indent_level: int, line: str, add_comma: bool=True):
|
|
124
|
-
added_line = ' '*flags.indent_size*indent_level + line
|
|
125
|
-
if add_comma and indent_level > 0:
|
|
126
|
-
added_line += ','
|
|
127
|
-
script_lines.append(added_line)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
# TODO: add tag values if not default
|
|
131
|
-
def generate_script(template, flags: GeneratorFlags) -> str:
|
|
132
|
-
indent_level = 0
|
|
133
|
-
script_lines = []
|
|
134
|
-
for codeblock in template.codeblocks:
|
|
135
|
-
if codeblock.name == 'bracket':
|
|
136
|
-
if codeblock.data['direct'] == 'open':
|
|
137
|
-
add_script_line(flags, script_lines, indent_level, 't.bracket(', False)
|
|
138
|
-
indent_level += 1
|
|
139
|
-
elif codeblock.data['direct'] == 'close':
|
|
140
|
-
indent_level -= 1
|
|
141
|
-
add_script_line(flags, script_lines, indent_level, ')')
|
|
142
|
-
continue
|
|
143
|
-
if codeblock.name == 'else':
|
|
144
|
-
add_script_line(flags, script_lines, indent_level, 't.else_()')
|
|
145
|
-
continue
|
|
146
|
-
|
|
147
|
-
method_name = TEMPLATE_METHOD_LOOKUP[codeblock.data['block']]
|
|
148
|
-
method_args = [f'"{codeblock.name}"']
|
|
149
|
-
if codeblock.name == 'dynamic':
|
|
150
|
-
method_args[0] = f'"{codeblock.data["data"]}"'
|
|
151
|
-
|
|
152
|
-
codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
|
|
153
|
-
if codeblock_args:
|
|
154
|
-
method_args.extend(codeblock_args)
|
|
155
|
-
if method_name in TARGET_CODEBLOCKS and codeblock.target.name != 'SELECTION':
|
|
156
|
-
method_args.append(f'target=Target.{codeblock.target.name}')
|
|
157
|
-
if codeblock.tags:
|
|
158
|
-
default_tags = get_default_tags(codeblock.data.get('block'), codeblock.name)
|
|
159
|
-
written_tags = {t: o for t, o in codeblock.tags.items() if default_tags[t] != o}
|
|
160
|
-
if written_tags:
|
|
161
|
-
method_args.append(f'tags={str(written_tags)}')
|
|
162
|
-
|
|
163
|
-
line = f't.{method_name}({", ".join(method_args)})'
|
|
164
|
-
add_script_line(flags, script_lines, indent_level, line)
|
|
165
|
-
return SCRIPT_START + '\n'.join(script_lines)
|
|
1
|
+
import dataclasses
|
|
2
|
+
import re
|
|
3
|
+
from dfpyre.items import *
|
|
4
|
+
from dfpyre.actiondump import get_default_tags
|
|
5
|
+
|
|
6
|
+
SCRIPT_START = '''from dfpyre import *
|
|
7
|
+
|
|
8
|
+
t = DFTemplate()
|
|
9
|
+
'''
|
|
10
|
+
|
|
11
|
+
TEMPLATE_METHOD_LOOKUP = {
|
|
12
|
+
'event': 'player_event',
|
|
13
|
+
'entity_event': 'entity_event',
|
|
14
|
+
'func': 'function',
|
|
15
|
+
'process': 'process',
|
|
16
|
+
'call_func': 'call_function',
|
|
17
|
+
'start_process': 'start_process',
|
|
18
|
+
'player_action': 'player_action',
|
|
19
|
+
'game_action': 'game_action',
|
|
20
|
+
'entity_action': 'entity_action',
|
|
21
|
+
'if_player': 'if_player',
|
|
22
|
+
'if_var': 'if_variable',
|
|
23
|
+
'if_game': 'if_game',
|
|
24
|
+
'if_entity': 'if_entity',
|
|
25
|
+
'else': 'else_',
|
|
26
|
+
'repeat': 'repeat',
|
|
27
|
+
'control': 'control',
|
|
28
|
+
'select_obj': 'select_object',
|
|
29
|
+
'set_var': 'set_variable'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
TARGET_CODEBLOCKS = {'player_action', 'entity_action', 'if_player', 'if_entity'}
|
|
33
|
+
VAR_SCOPES = {'unsaved': 'g', 'saved': 's', 'local': 'l', 'line': 'i'}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclasses.dataclass
|
|
37
|
+
class GeneratorFlags:
|
|
38
|
+
indent_size: int
|
|
39
|
+
literal_shorthand: bool
|
|
40
|
+
var_shorthand: bool
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def item_to_string(class_name: str, i: item):
|
|
44
|
+
i.nbt.data.pop('~DF_NBT', None)
|
|
45
|
+
stripped_id = i.get_id().replace('minecraft:', '')
|
|
46
|
+
if i.nbt.key_set() == {'~id', '~count'}:
|
|
47
|
+
if i.get_count() == 1:
|
|
48
|
+
return f'{class_name}("{stripped_id}")'
|
|
49
|
+
return f'{class_name}("{stripped_id}", {i.get_count()})'
|
|
50
|
+
return f'{class_name}.from_nbt("""{i.get_nbt()}""")'
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def argument_item_to_string(flags: GeneratorFlags, arg_item: object) -> str:
|
|
54
|
+
class_name = arg_item.__class__.__name__
|
|
55
|
+
if isinstance(arg_item, item):
|
|
56
|
+
return item_to_string(class_name, arg_item)
|
|
57
|
+
|
|
58
|
+
if isinstance(arg_item, string):
|
|
59
|
+
value = arg_item.value.replace('\n', '\\n')
|
|
60
|
+
return f'{class_name}("{value}")'
|
|
61
|
+
|
|
62
|
+
if isinstance(arg_item, text):
|
|
63
|
+
value = arg_item.value.replace('\n', '\\n')
|
|
64
|
+
if flags.literal_shorthand:
|
|
65
|
+
return f'"{value}"'
|
|
66
|
+
return f'{class_name}("{value}")'
|
|
67
|
+
|
|
68
|
+
if isinstance(arg_item, num):
|
|
69
|
+
if not re.match(NUMBER_REGEX, str(arg_item.value)):
|
|
70
|
+
return f'{class_name}("{arg_item.value}")'
|
|
71
|
+
if flags.literal_shorthand:
|
|
72
|
+
return str(arg_item.value)
|
|
73
|
+
return f'{class_name}({arg_item.value})'
|
|
74
|
+
|
|
75
|
+
if isinstance(arg_item, loc):
|
|
76
|
+
loc_components = [arg_item.x, arg_item.y, arg_item.z]
|
|
77
|
+
if arg_item.pitch != 0:
|
|
78
|
+
loc_components.append(arg_item.pitch)
|
|
79
|
+
if arg_item.yaw != 0:
|
|
80
|
+
loc_components.append(arg_item.yaw)
|
|
81
|
+
return f'{class_name}({", ".join(str(c) for c in loc_components)})'
|
|
82
|
+
|
|
83
|
+
if isinstance(arg_item, var):
|
|
84
|
+
if flags.var_shorthand:
|
|
85
|
+
return f'"${VAR_SCOPES[arg_item.scope]}{arg_item.name}"'
|
|
86
|
+
if arg_item.scope == 'unsaved':
|
|
87
|
+
return f'{class_name}("{arg_item.name}")'
|
|
88
|
+
return f'{class_name}("{arg_item.name}", "{arg_item.scope}")'
|
|
89
|
+
|
|
90
|
+
if isinstance(arg_item, sound):
|
|
91
|
+
return f'{class_name}("{arg_item.name}", {arg_item.pitch}, {arg_item.vol})'
|
|
92
|
+
|
|
93
|
+
if isinstance(arg_item, particle):
|
|
94
|
+
return f'{class_name}({arg_item.particle_data})'
|
|
95
|
+
|
|
96
|
+
if isinstance(arg_item, potion):
|
|
97
|
+
return f'{class_name}("{arg_item.name}", {arg_item.dur}, {arg_item.amp})'
|
|
98
|
+
|
|
99
|
+
if isinstance(arg_item, gamevalue):
|
|
100
|
+
if arg_item.target == 'Default':
|
|
101
|
+
return f'{class_name}("{arg_item.name}")'
|
|
102
|
+
return f'{class_name}("{arg_item.name}", "{arg_item.target}")'
|
|
103
|
+
|
|
104
|
+
if isinstance(arg_item, parameter):
|
|
105
|
+
param_type_class_name = arg_item.param_type.__class__.__name__
|
|
106
|
+
param_args = [f'"{arg_item.name}"', f'{param_type_class_name}.{arg_item.param_type.name}']
|
|
107
|
+
if arg_item.plural:
|
|
108
|
+
param_args.append('plural=True')
|
|
109
|
+
if arg_item.optional:
|
|
110
|
+
param_args.append('optional=True')
|
|
111
|
+
if arg_item.default_value is not None:
|
|
112
|
+
param_args.append(f'default_value={argument_item_to_string(flags, arg_item.default_value)}')
|
|
113
|
+
if arg_item.description:
|
|
114
|
+
param_args.append(f'description="{arg_item.description}"')
|
|
115
|
+
if arg_item.note:
|
|
116
|
+
param_args.append(f'note="{arg_item.note}"')
|
|
117
|
+
return f'{class_name}({", ".join(param_args)})'
|
|
118
|
+
|
|
119
|
+
if isinstance(arg_item, vector):
|
|
120
|
+
return f'{class_name}({arg_item.x}, {arg_item.y}, {arg_item.z})'
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def add_script_line(flags: GeneratorFlags, script_lines: list[str], indent_level: int, line: str, add_comma: bool=True):
|
|
124
|
+
added_line = ' '*flags.indent_size*indent_level + line
|
|
125
|
+
if add_comma and indent_level > 0:
|
|
126
|
+
added_line += ','
|
|
127
|
+
script_lines.append(added_line)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# TODO: add tag values if not default
|
|
131
|
+
def generate_script(template, flags: GeneratorFlags) -> str:
|
|
132
|
+
indent_level = 0
|
|
133
|
+
script_lines = []
|
|
134
|
+
for codeblock in template.codeblocks:
|
|
135
|
+
if codeblock.name == 'bracket':
|
|
136
|
+
if codeblock.data['direct'] == 'open':
|
|
137
|
+
add_script_line(flags, script_lines, indent_level, 't.bracket(', False)
|
|
138
|
+
indent_level += 1
|
|
139
|
+
elif codeblock.data['direct'] == 'close':
|
|
140
|
+
indent_level -= 1
|
|
141
|
+
add_script_line(flags, script_lines, indent_level, ')')
|
|
142
|
+
continue
|
|
143
|
+
if codeblock.name == 'else':
|
|
144
|
+
add_script_line(flags, script_lines, indent_level, 't.else_()')
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
method_name = TEMPLATE_METHOD_LOOKUP[codeblock.data['block']]
|
|
148
|
+
method_args = [f'"{codeblock.name}"']
|
|
149
|
+
if codeblock.name == 'dynamic':
|
|
150
|
+
method_args[0] = f'"{codeblock.data["data"]}"'
|
|
151
|
+
|
|
152
|
+
codeblock_args = [argument_item_to_string(flags, i) for i in codeblock.args]
|
|
153
|
+
if codeblock_args:
|
|
154
|
+
method_args.extend(codeblock_args)
|
|
155
|
+
if method_name in TARGET_CODEBLOCKS and codeblock.target.name != 'SELECTION':
|
|
156
|
+
method_args.append(f'target=Target.{codeblock.target.name}')
|
|
157
|
+
if codeblock.tags:
|
|
158
|
+
default_tags = get_default_tags(codeblock.data.get('block'), codeblock.name)
|
|
159
|
+
written_tags = {t: o for t, o in codeblock.tags.items() if default_tags[t] != o}
|
|
160
|
+
if written_tags:
|
|
161
|
+
method_args.append(f'tags={str(written_tags)}')
|
|
162
|
+
|
|
163
|
+
line = f't.{method_name}({", ".join(method_args)})'
|
|
164
|
+
add_script_line(flags, script_lines, indent_level, line)
|
|
165
|
+
return SCRIPT_START + '\n'.join(script_lines)
|
dfpyre/style.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from mcitemlib.style import STYLE_CODE_REGEX, FORMAT_CODES, StyledString
|
|
3
|
-
|
|
4
|
-
def is_ampersand_coded(s: str) -> bool:
|
|
5
|
-
return bool(re.match(STYLE_CODE_REGEX, s))
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def ampersand_to_minimessage(ampersand_code: str) -> str:
|
|
9
|
-
ampersand_code = ampersand_code.replace('&r', '<reset>') # bad but should work most of the time
|
|
10
|
-
styled_string = StyledString.from_codes(ampersand_code)
|
|
11
|
-
formatted_string_list = []
|
|
12
|
-
for substring in styled_string.substrings:
|
|
13
|
-
formatted_substring_list = []
|
|
14
|
-
for style_type, value in substring.data.items():
|
|
15
|
-
if style_type in FORMAT_CODES.values() and value:
|
|
16
|
-
formatted_substring_list.append(f'<{style_type}>')
|
|
17
|
-
if style_type == 'color':
|
|
18
|
-
formatted_substring_list.append(f'<{value}>')
|
|
19
|
-
|
|
20
|
-
formatted_substring_list.append(substring.data['text'])
|
|
21
|
-
formatted_string_list.append(''.join(formatted_substring_list))
|
|
1
|
+
import re
|
|
2
|
+
from mcitemlib.style import STYLE_CODE_REGEX, FORMAT_CODES, StyledString
|
|
3
|
+
|
|
4
|
+
def is_ampersand_coded(s: str) -> bool:
|
|
5
|
+
return bool(re.match(STYLE_CODE_REGEX, s))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ampersand_to_minimessage(ampersand_code: str) -> str:
|
|
9
|
+
ampersand_code = ampersand_code.replace('&r', '<reset>') # bad but should work most of the time
|
|
10
|
+
styled_string = StyledString.from_codes(ampersand_code)
|
|
11
|
+
formatted_string_list = []
|
|
12
|
+
for substring in styled_string.substrings:
|
|
13
|
+
formatted_substring_list = []
|
|
14
|
+
for style_type, value in substring.data.items():
|
|
15
|
+
if style_type in FORMAT_CODES.values() and value:
|
|
16
|
+
formatted_substring_list.append(f'<{style_type}>')
|
|
17
|
+
if style_type == 'color':
|
|
18
|
+
formatted_substring_list.append(f'<{value}>')
|
|
19
|
+
|
|
20
|
+
formatted_substring_list.append(substring.data['text'])
|
|
21
|
+
formatted_string_list.append(''.join(formatted_substring_list))
|
|
22
22
|
return ''.join(formatted_string_list)
|
dfpyre/util.py
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import gzip
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
COL_WARN = '\x1b[33m'
|
|
6
|
-
COL_RESET = '\x1b[0m'
|
|
7
|
-
COL_SUCCESS = '\x1b[32m'
|
|
8
|
-
COL_ERROR = '\x1b[31m'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class PyreException(Exception):
|
|
12
|
-
pass
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def warn(message: str):
|
|
16
|
-
print(f'{COL_WARN}! WARNING ! {message}{COL_RESET}')
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def df_encode(json_string: str) -> str:
|
|
20
|
-
"""
|
|
21
|
-
Encodes a stringified json.
|
|
22
|
-
"""
|
|
23
|
-
encoded_string = gzip.compress(json_string.encode('utf-8'))
|
|
24
|
-
return base64.b64encode(encoded_string).decode('utf-8')
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def df_decode(encoded_string: str) -> str:
|
|
28
|
-
return gzip.decompress(base64.b64decode(encoded_string)).decode('utf-8')
|
|
1
|
+
import base64
|
|
2
|
+
import gzip
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
COL_WARN = '\x1b[33m'
|
|
6
|
+
COL_RESET = '\x1b[0m'
|
|
7
|
+
COL_SUCCESS = '\x1b[32m'
|
|
8
|
+
COL_ERROR = '\x1b[31m'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PyreException(Exception):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def warn(message: str):
|
|
16
|
+
print(f'{COL_WARN}! WARNING ! {message}{COL_RESET}')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def df_encode(json_string: str) -> str:
|
|
20
|
+
"""
|
|
21
|
+
Encodes a stringified json.
|
|
22
|
+
"""
|
|
23
|
+
encoded_string = gzip.compress(json_string.encode('utf-8'))
|
|
24
|
+
return base64.b64encode(encoded_string).decode('utf-8')
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def df_decode(encoded_string: str) -> str:
|
|
28
|
+
return gzip.decompress(base64.b64decode(encoded_string)).decode('utf-8')
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Amp
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Amp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dfpyre
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.11
|
|
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
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Requires-Dist: mcitemlib (>=0.3.
|
|
15
|
+
Requires-Dist: mcitemlib (>=0.3.4,<0.4.0)
|
|
16
16
|
Project-URL: Repository, https://github.com/Amp63/pyre
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
dfpyre/__init__.py,sha256=apPsSxJ1Tztfl71MoORoSmDfX7LyKLYlLwOGeLQUitw,25
|
|
2
|
+
dfpyre/actiondump.py,sha256=MVI1kVJBNpab882Tgqo-xtemiBN2W1_2OcopBcRupWQ,2587
|
|
3
|
+
dfpyre/data/actiondump_min.json,sha256=hFcIbG_G55FWwqRSW6X77ZrKkQiXLs4CGgJrZgyR2Gg,1938799
|
|
4
|
+
dfpyre/items.py,sha256=StQnkvGAZj3mb7qG3bMyuuiRaSIttyW1Azs139e5c_4,11374
|
|
5
|
+
dfpyre/pyre.py,sha256=0RTXNc335goXwiUddq5Yw8siYDAjVuH0rtT8y4SKI0A,18316
|
|
6
|
+
dfpyre/scriptgen.py,sha256=ArEBAYVVWEhABzcur6rtnZ9uvgg6kyZqqe5G4uyLamw,6344
|
|
7
|
+
dfpyre/style.py,sha256=mLW1CFvvi8_9fk8JaH10I5S4WI0YBdQIXHtI3G_4sR8,980
|
|
8
|
+
dfpyre/util.py,sha256=gHIPPVD0dcLPAaN1M5EnNgxenarwlxfRKN4xno1YJHM,582
|
|
9
|
+
dfpyre-0.7.11.dist-info/LICENSE,sha256=_vuDskB0ja2c-Fgm7Gt8Q8cO9NsLNpZAVyvmZwX7E6o,1060
|
|
10
|
+
dfpyre-0.7.11.dist-info/METADATA,sha256=3u06h2Hu9-_E-oApApvT6xB2yXJcsSpcyPV3C-Y7fjg,11755
|
|
11
|
+
dfpyre-0.7.11.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
12
|
+
dfpyre-0.7.11.dist-info/RECORD,,
|
dfpyre-0.7.10.dist-info/RECORD
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
dfpyre/__init__.py,sha256=apPsSxJ1Tztfl71MoORoSmDfX7LyKLYlLwOGeLQUitw,25
|
|
2
|
-
dfpyre/actiondump.py,sha256=YR5h0ZjgyqNkHUCkLLKS0ovMFZQ8WSKuJQzGncT27cA,2664
|
|
3
|
-
dfpyre/data/actiondump_min.json,sha256=hFcIbG_G55FWwqRSW6X77ZrKkQiXLs4CGgJrZgyR2Gg,1938799
|
|
4
|
-
dfpyre/items.py,sha256=WIiuslk6qyPUWSndDFEUqz_TNGUgIb0YgXrwh2Lokfs,11746
|
|
5
|
-
dfpyre/pyre.py,sha256=swF4up0nHY0NJHLR08YrMZfot62GYaqavEVwGZdXUIw,18773
|
|
6
|
-
dfpyre/scriptgen.py,sha256=bUjT9iIzd5fhXOG2hQ7hWY8C-hwTRJlI0i6Fjthulic,6509
|
|
7
|
-
dfpyre/style.py,sha256=YRSKEg5r8rkZH62WkRQYbTPgTWVVGVXLnx4edShs0NM,1001
|
|
8
|
-
dfpyre/util.py,sha256=KThtsPQh4Ep3UXPvJGw5jrzEcM4cDqDG5IG1FXUQROI,610
|
|
9
|
-
dfpyre-0.7.10.dist-info/LICENSE,sha256=nqCBVqcbIX-9lhVDarggfrjgNZoPlKKlyl0-hOPS2wQ,1081
|
|
10
|
-
dfpyre-0.7.10.dist-info/METADATA,sha256=8Nx4Q8QFHk4fKoMb1FDin0mUcjcgtNTzv0Idd0QnqJo,11755
|
|
11
|
-
dfpyre-0.7.10.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
12
|
-
dfpyre-0.7.10.dist-info/RECORD,,
|
|
File without changes
|