mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
Create EntityClassError exception.
Much more useful than Python's SyntaxError (and much less confusing).
This commit is contained in:
parent
ae942afe5c
commit
25e545616a
1 changed files with 11 additions and 2 deletions
|
@ -25,6 +25,14 @@ from .qfplist import pldata
|
|||
|
||||
MAX_FLAGS = 8
|
||||
|
||||
class EntityClassError(Exception):
|
||||
def __init__(self, fname, line, message):
|
||||
Exception.__init__(self, "%s:%d: %s" % (fname, line, message))
|
||||
self.line = line
|
||||
|
||||
def entclass_error(self, msg):
|
||||
raise EntityClassError(self.filename, self.line, msg)
|
||||
|
||||
class EntityClass:
|
||||
def __init__(self, name, color, size, flagnames, comment):
|
||||
self.name = name
|
||||
|
@ -38,6 +46,7 @@ class EntityClass:
|
|||
@classmethod
|
||||
def from_quaked(cls, text, filename, line = 0):
|
||||
script = Script(filename, text)
|
||||
script.error = entclass_error.__get__(script, Script)
|
||||
if line:
|
||||
script.line = line
|
||||
script.getToken() # skip over the leading '/*QUAKED'
|
||||
|
@ -78,11 +87,11 @@ class EntityClass:
|
|||
@classmethod
|
||||
def parse_vector(cls, script):
|
||||
if script.getToken() != "(":
|
||||
raise SyntaxError
|
||||
script.error("Missing (")
|
||||
v = (float(script.getToken()), float(script.getToken()),
|
||||
float(script.getToken()))
|
||||
if script.getToken() != ")":
|
||||
raise SyntaxError
|
||||
script.error("Missing )")
|
||||
return v
|
||||
@classmethod
|
||||
def parse_size(cls, script):
|
||||
|
|
Loading…
Reference in a new issue