Files
Paradise/tools/maplint/source/common.py
warriorstar-orion 499dbf0e06 port: tgstation maplint (#21390)
* 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.
2023-07-26 18:50:31 +01: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']