mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-27 09:41:40 +00:00
Ports and adapts TG's maplint, not all checks it has are present, this is just the first iteration. Updated python dependency to 3.11.9. Updated bootstrap. Fixed various maps to not fail maplint.
37 lines
756 B
Python
37 lines
756 B
Python
import re
|
|
from dataclasses import dataclass
|
|
|
|
from .error import MapParseError
|
|
|
|
REGEX_TYPEPATH = re.compile(r'^/[\w/]+$')
|
|
|
|
class Typepath:
|
|
path: str
|
|
segments: list[str]
|
|
|
|
def __init__(self, path):
|
|
if not REGEX_TYPEPATH.match(path):
|
|
raise MapParseError(f"Invalid typepath {path!r}.")
|
|
|
|
self.path = path
|
|
self.segments = path.split('/')[1:]
|
|
|
|
def __eq__(self, other):
|
|
if not isinstance(other, Typepath):
|
|
return False
|
|
|
|
return self.path == other.path
|
|
|
|
def __str__(self) -> str:
|
|
return self.path
|
|
|
|
@dataclass
|
|
class Filename:
|
|
path: str
|
|
|
|
@dataclass
|
|
class Null:
|
|
pass
|
|
|
|
Constant = str | float | Filename | Typepath | Null | list['Constant'] | dict['Constant', 'Constant']
|