mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-21 15:51:31 +00:00
* port: tgstation maplint * Actually add the thing and try using setup-python GH action * .python-version is gitignored so * add json5 to requirements * Run the cheaper, more likely to succeed checks first. * use version of pyyaml that doesn't have setuptools compat issues * Add check for grilles on top of spawners.
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']
|