minecraft-datapack-language 15.4.27__py3-none-any.whl → 15.4.29__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.
Files changed (27) hide show
  1. minecraft_datapack_language/__init__.py +17 -2
  2. minecraft_datapack_language/_version.py +2 -2
  3. minecraft_datapack_language/ast_nodes.py +87 -59
  4. minecraft_datapack_language/mdl_compiler.py +470 -0
  5. minecraft_datapack_language/mdl_errors.py +14 -0
  6. minecraft_datapack_language/mdl_lexer.py +624 -0
  7. minecraft_datapack_language/mdl_parser.py +573 -0
  8. minecraft_datapack_language-15.4.29.dist-info/METADATA +266 -0
  9. minecraft_datapack_language-15.4.29.dist-info/RECORD +16 -0
  10. minecraft_datapack_language/cli.py +0 -159
  11. minecraft_datapack_language/cli_build.py +0 -1292
  12. minecraft_datapack_language/cli_check.py +0 -155
  13. minecraft_datapack_language/cli_colors.py +0 -264
  14. minecraft_datapack_language/cli_help.py +0 -508
  15. minecraft_datapack_language/cli_new.py +0 -300
  16. minecraft_datapack_language/cli_utils.py +0 -276
  17. minecraft_datapack_language/expression_processor.py +0 -352
  18. minecraft_datapack_language/linter.py +0 -409
  19. minecraft_datapack_language/mdl_lexer_js.py +0 -754
  20. minecraft_datapack_language/mdl_parser_js.py +0 -1049
  21. minecraft_datapack_language/pack.py +0 -758
  22. minecraft_datapack_language-15.4.27.dist-info/METADATA +0 -1274
  23. minecraft_datapack_language-15.4.27.dist-info/RECORD +0 -25
  24. {minecraft_datapack_language-15.4.27.dist-info → minecraft_datapack_language-15.4.29.dist-info}/WHEEL +0 -0
  25. {minecraft_datapack_language-15.4.27.dist-info → minecraft_datapack_language-15.4.29.dist-info}/entry_points.txt +0 -0
  26. {minecraft_datapack_language-15.4.27.dist-info → minecraft_datapack_language-15.4.29.dist-info}/licenses/LICENSE +0 -0
  27. {minecraft_datapack_language-15.4.27.dist-info → minecraft_datapack_language-15.4.29.dist-info}/top_level.txt +0 -0
@@ -1,155 +0,0 @@
1
- """
2
- CLI Check Functions - Validation and error checking for MDL files
3
- """
4
-
5
- import sys
6
- from pathlib import Path
7
- from typing import Optional
8
-
9
- from .mdl_errors import MDLErrorCollector, create_error, MDLFileError
10
- from .mdl_linter import lint_mdl_file, lint_mdl_directory
11
-
12
-
13
- def lint_mdl_file_wrapper(file_path: str, verbose: bool = False, ignore_warnings: bool = False):
14
- """Wrapper function for linting a single MDL file with error handling."""
15
- error_collector = MDLErrorCollector()
16
-
17
- try:
18
- path = Path(file_path)
19
-
20
- # Validate file exists
21
- if not path.exists():
22
- error_collector.add_error(create_error(
23
- MDLFileError,
24
- f"File does not exist: {file_path}",
25
- file_path=file_path,
26
- suggestion="Check the file path and ensure the file exists."
27
- ))
28
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
29
- error_collector.raise_if_errors()
30
- return
31
-
32
- # Validate file is an MDL file
33
- if path.suffix != '.mdl':
34
- error_collector.add_error(create_error(
35
- MDLFileError,
36
- f"File is not an MDL file: {file_path}",
37
- file_path=file_path,
38
- suggestion="Ensure the file has a .mdl extension."
39
- ))
40
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
41
- error_collector.raise_if_errors()
42
- return
43
-
44
- # Perform linting
45
- try:
46
- issues = lint_mdl_file(str(path))
47
-
48
- # Check if there are any errors
49
- errors = [issue for issue in issues if issue.severity == 'error']
50
- warnings = [issue for issue in issues if issue.severity == 'warning']
51
-
52
- if errors:
53
- # Report errors
54
- print(f"[CHECK] Found {len(errors)} error(s) in: {file_path}")
55
- for i, issue in enumerate(errors, 1):
56
- print(f"Error {i}: {issue.message}")
57
- if issue.suggestion:
58
- print(f" Suggestion: {issue.suggestion}")
59
- if issue.code:
60
- print(f" Code: {issue.code}")
61
- print()
62
-
63
- # Exit with error code
64
- sys.exit(1)
65
- elif warnings and not ignore_warnings:
66
- # Report warnings
67
- print(f"[CHECK] Found {len(warnings)} warning(s) in: {file_path}")
68
- for i, issue in enumerate(warnings, 1):
69
- print(f"Warning {i}: {issue.message}")
70
- if issue.suggestion:
71
- print(f" Suggestion: {issue.suggestion}")
72
- if issue.code:
73
- print(f" Code: {issue.code}")
74
- print()
75
-
76
- print(f"[CHECK] Successfully checked: {file_path}")
77
- print("[OK] No errors found!")
78
-
79
- except Exception as e:
80
- error_collector.add_error(create_error(
81
- MDLFileError,
82
- f"Error during linting: {str(e)}",
83
- file_path=file_path,
84
- suggestion="Check the file syntax and try again."
85
- ))
86
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
87
- error_collector.raise_if_errors()
88
-
89
- except Exception as e:
90
- error_collector.add_error(create_error(
91
- MDLFileError,
92
- f"Unexpected error: {str(e)}",
93
- file_path=file_path,
94
- suggestion="Check the file and try again. If the problem persists, report this as a bug."
95
- ))
96
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
97
- error_collector.raise_if_errors()
98
-
99
-
100
- def lint_mdl_directory_wrapper(directory_path: str, verbose: bool = False, ignore_warnings: bool = False):
101
- """Wrapper function for linting a directory of MDL files with error handling."""
102
- error_collector = MDLErrorCollector()
103
-
104
- try:
105
- directory = Path(directory_path)
106
-
107
- # Validate directory exists
108
- if not directory.exists():
109
- error_collector.add_error(create_error(
110
- MDLFileError,
111
- f"Directory does not exist: {directory_path}",
112
- file_path=directory_path,
113
- suggestion="Check the directory path and ensure it exists."
114
- ))
115
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
116
- error_collector.raise_if_errors()
117
- return
118
-
119
- # Validate it's a directory
120
- if not directory.is_dir():
121
- error_collector.add_error(create_error(
122
- MDLFileError,
123
- f"Path is not a directory: {directory_path}",
124
- file_path=directory_path,
125
- suggestion="Provide a valid directory path."
126
- ))
127
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
128
- error_collector.raise_if_errors()
129
- return
130
-
131
- # Perform directory linting
132
- try:
133
- lint_mdl_directory(str(directory), verbose)
134
- print(f"[CHECK] Successfully checked directory: {directory_path}")
135
- print("[OK] No errors found!")
136
-
137
- except Exception as e:
138
- error_collector.add_error(create_error(
139
- MDLFileError,
140
- f"Error during directory linting: {str(e)}",
141
- file_path=directory_path,
142
- suggestion="Check the directory contents and try again."
143
- ))
144
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
145
- error_collector.raise_if_errors()
146
-
147
- except Exception as e:
148
- error_collector.add_error(create_error(
149
- MDLFileError,
150
- f"Unexpected error: {str(e)}",
151
- file_path=directory_path,
152
- suggestion="Check the directory and try again. If the problem persists, report this as a bug."
153
- ))
154
- error_collector.print_errors(verbose=True, ignore_warnings=ignore_warnings)
155
- error_collector.raise_if_errors()
@@ -1,264 +0,0 @@
1
- """
2
- CLI Color Utilities - Windows-compatible color system for MDL CLI
3
- Provides vibrant colors without unicode characters for maximum readability
4
- """
5
-
6
- import os
7
- import sys
8
- from typing import Optional
9
-
10
-
11
- class Colors:
12
- """Color constants for CLI output - Windows compatible."""
13
-
14
- # Basic colors using ANSI escape codes
15
- RESET = "\033[0m"
16
- BOLD = "\033[1m"
17
- DIM = "\033[2m"
18
- UNDERLINE = "\033[4m"
19
- BLINK = "\033[5m"
20
- REVERSE = "\033[7m"
21
- HIDDEN = "\033[8m"
22
-
23
- # Foreground colors
24
- BLACK = "\033[30m"
25
- RED = "\033[31m"
26
- GREEN = "\033[32m"
27
- YELLOW = "\033[33m"
28
- BLUE = "\033[34m"
29
- MAGENTA = "\033[35m"
30
- CYAN = "\033[36m"
31
- WHITE = "\033[37m"
32
-
33
- # Bright foreground colors
34
- BRIGHT_BLACK = "\033[90m"
35
- BRIGHT_RED = "\033[91m"
36
- BRIGHT_GREEN = "\033[92m"
37
- BRIGHT_YELLOW = "\033[93m"
38
- BRIGHT_BLUE = "\033[94m"
39
- BRIGHT_MAGENTA = "\033[95m"
40
- BRIGHT_CYAN = "\033[96m"
41
- BRIGHT_WHITE = "\033[97m"
42
-
43
- # Background colors
44
- BG_BLACK = "\033[40m"
45
- BG_RED = "\033[41m"
46
- BG_GREEN = "\033[42m"
47
- BG_YELLOW = "\033[43m"
48
- BG_BLUE = "\033[44m"
49
- BG_MAGENTA = "\033[45m"
50
- BG_CYAN = "\033[46m"
51
- BG_WHITE = "\033[47m"
52
-
53
- # Bright background colors
54
- BG_BRIGHT_BLACK = "\033[100m"
55
- BG_BRIGHT_RED = "\033[101m"
56
- BG_BRIGHT_GREEN = "\033[102m"
57
- BG_BRIGHT_YELLOW = "\033[103m"
58
- BG_BRIGHT_BLUE = "\033[104m"
59
- BG_BRIGHT_MAGENTA = "\033[105m"
60
- BG_BRIGHT_CYAN = "\033[106m"
61
- BG_BRIGHT_WHITE = "\033[107m"
62
-
63
-
64
- class ColorFormatter:
65
- """Formats text with colors and styling for CLI output."""
66
-
67
- def __init__(self, force_colors: bool = False):
68
- """Initialize color formatter.
69
-
70
- Args:
71
- force_colors: If True, force colors even when not supported
72
- """
73
- self.colors_enabled = self._check_color_support() or force_colors
74
-
75
- def _check_color_support(self) -> bool:
76
- """Check if the terminal supports colors."""
77
- # Check if we're on Windows
78
- if os.name == 'nt':
79
- # On Windows, check if we're in a modern terminal
80
- try:
81
- import colorama
82
- return True
83
- except ImportError:
84
- # Check if we're in a modern Windows terminal
85
- return 'TERM' in os.environ and os.environ['TERM'] != 'dumb'
86
- else:
87
- # On Unix-like systems, check if we have a TTY
88
- return hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
89
-
90
- def _format(self, text: str, *colors: str) -> str:
91
- """Format text with colors if enabled."""
92
- if not self.colors_enabled:
93
- return text
94
-
95
- color_codes = ''.join(colors)
96
- return f"{color_codes}{text}{Colors.RESET}"
97
-
98
- def header(self, text: str) -> str:
99
- """Format a header with bright cyan and bold."""
100
- return self._format(text, Colors.BRIGHT_CYAN, Colors.BOLD)
101
-
102
- def title(self, text: str) -> str:
103
- """Format a title with bright blue and bold."""
104
- return self._format(text, Colors.BRIGHT_BLUE, Colors.BOLD)
105
-
106
- def command(self, text: str) -> str:
107
- """Format a command with bright green."""
108
- return self._format(text, Colors.BRIGHT_GREEN)
109
-
110
- def option(self, text: str) -> str:
111
- """Format an option with bright yellow."""
112
- return self._format(text, Colors.BRIGHT_YELLOW)
113
-
114
- def success(self, text: str) -> str:
115
- """Format success message with bright green."""
116
- return self._format(text, Colors.BRIGHT_GREEN)
117
-
118
- def warning(self, text: str) -> str:
119
- """Format warning message with bright yellow."""
120
- return self._format(text, Colors.BRIGHT_YELLOW)
121
-
122
- def error(self, text: str) -> str:
123
- """Format error message with bright red."""
124
- return self._format(text, Colors.BRIGHT_RED)
125
-
126
- def info(self, text: str) -> str:
127
- """Format info message with bright cyan."""
128
- return self._format(text, Colors.BRIGHT_CYAN)
129
-
130
- def highlight(self, text: str) -> str:
131
- """Format highlighted text with bright magenta."""
132
- return self._format(text, Colors.BRIGHT_MAGENTA)
133
-
134
- def dim(self, text: str) -> str:
135
- """Format dimmed text."""
136
- return self._format(text, Colors.DIM)
137
-
138
- def bold(self, text: str) -> str:
139
- """Format bold text."""
140
- return self._format(text, Colors.BOLD)
141
-
142
- def underline(self, text: str) -> str:
143
- """Format underlined text."""
144
- return self._format(text, Colors.UNDERLINE)
145
-
146
- def separator(self, char: str = "=", length: int = 60) -> str:
147
- """Create a colored separator line."""
148
- separator_line = char * length
149
- return self._format(separator_line, Colors.BRIGHT_BLUE)
150
-
151
- def section(self, title: str, char: str = "=") -> str:
152
- """Create a colored section header."""
153
- line_length = max(60, len(title) + 4)
154
- left_pad = (line_length - len(title)) // 2
155
- right_pad = line_length - len(title) - left_pad
156
-
157
- section = f"{char * left_pad} {title} {char * right_pad}"
158
- return self._format(section, Colors.BRIGHT_BLUE, Colors.BOLD)
159
-
160
- def bullet(self, text: str, bullet_char: str = "•") -> str:
161
- """Format a bullet point."""
162
- return self._format(f"{bullet_char} {text}", Colors.BRIGHT_WHITE)
163
-
164
- def code(self, text: str) -> str:
165
- """Format code or technical text."""
166
- return self._format(text, Colors.BRIGHT_YELLOW, Colors.BG_BLACK)
167
-
168
- def file_path(self, text: str) -> str:
169
- """Format file paths."""
170
- return self._format(text, Colors.BRIGHT_CYAN)
171
-
172
- def line_number(self, text: str) -> str:
173
- """Format line numbers."""
174
- return self._format(text, Colors.BRIGHT_YELLOW)
175
-
176
- def column_number(self, text: str) -> str:
177
- """Format column numbers."""
178
- return self._format(text, Colors.BRIGHT_YELLOW)
179
-
180
- def error_type(self, text: str) -> str:
181
- """Format error type labels."""
182
- return self._format(text, Colors.BRIGHT_RED, Colors.BOLD)
183
-
184
- def suggestion(self, text: str) -> str:
185
- """Format suggestions."""
186
- return self._format(text, Colors.BRIGHT_GREEN, Colors.BOLD)
187
-
188
- def context(self, text: str) -> str:
189
- """Format context information."""
190
- return self._format(text, Colors.DIM)
191
-
192
-
193
- # Global color formatter instance
194
- color = ColorFormatter()
195
-
196
-
197
- def print_header(text: str):
198
- """Print a formatted header."""
199
- print(color.header(text))
200
-
201
-
202
- def print_title(text: str):
203
- """Print a formatted title."""
204
- print(color.title(text))
205
-
206
-
207
- def print_section(title: str):
208
- """Print a formatted section."""
209
- print(color.section(title))
210
-
211
-
212
- def print_separator(char: str = "=", length: int = 60):
213
- """Print a formatted separator."""
214
- print(color.separator(char, length))
215
-
216
-
217
- def print_success(text: str):
218
- """Print a success message."""
219
- print(color.success(text))
220
-
221
-
222
- def print_warning(text: str):
223
- """Print a warning message."""
224
- print(color.warning(text))
225
-
226
-
227
- def print_error(text: str):
228
- """Print an error message."""
229
- print(color.error(text))
230
-
231
-
232
- def print_info(text: str):
233
- """Print an info message."""
234
- print(color.info(text))
235
-
236
-
237
- def print_bullet(text: str):
238
- """Print a bullet point."""
239
- print(color.bullet(text))
240
-
241
-
242
- def print_code(text: str):
243
- """Print formatted code."""
244
- print(color.code(text))
245
-
246
-
247
- def print_file_path(text: str):
248
- """Print a formatted file path."""
249
- print(color.file_path(text))
250
-
251
-
252
- def print_error_type(text: str):
253
- """Print a formatted error type."""
254
- print(color.error_type(text))
255
-
256
-
257
- def print_suggestion(text: str):
258
- """Print a formatted suggestion."""
259
- print(color.suggestion(text))
260
-
261
-
262
- def print_context(text: str):
263
- """Print formatted context."""
264
- print(color.context(text))