added readInt..... jeez, am i rebuilding a string scanner here?

This commit is contained in:
David Vierra 2010-10-21 18:45:36 -10:00
parent b17618443f
commit 394d0b02f5

20
mce.py
View File

@ -113,12 +113,28 @@ class mce(object):
debug = False
needsSave = False;
def readInt(self, command):
try:
val = int(command.pop(0))
except ValueError:
raise UsageError, "Cannot understand numeric input"
return val
def readBox(self, command):
sourcePoint = self.readPoint(command)
sourceSize = self.readPoint(command, isPoint = False)
sourcePoint = self.readIntPoint(command)
if command[0].lower() == "to":
command.pop(0)
sourcePoint2 = self.readIntPoint(command)
else:
sourceSize = self.readIntPoint(command, isPoint = False)
box = BoundingBox(sourcePoint, sourceSize)
return box
def readIntPoint(self, command, isPoint = True):
point = self.readPoint(self, command, isPoint)
point = map(int, map(floor(point)))
return point
def readPoint(self, command, isPoint = True):
try:
word = command.pop(0)