Files
Aurora.3/tools/maplint/source/common.py
Fluffy 49d1ea41a6 Ports and adapts TG's maplint (#18873)
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.
2024-04-08 08:27:27 +00:00

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']