added readInt..... jeez, am i rebuilding a string scanner here?
This commit is contained in:
parent
b17618443f
commit
394d0b02f5
20
mce.py
20
mce.py
@ -113,12 +113,28 @@ class mce(object):
|
|||||||
debug = False
|
debug = False
|
||||||
needsSave = 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):
|
def readBox(self, command):
|
||||||
sourcePoint = self.readPoint(command)
|
sourcePoint = self.readIntPoint(command)
|
||||||
sourceSize = self.readPoint(command, isPoint = False)
|
if command[0].lower() == "to":
|
||||||
|
command.pop(0)
|
||||||
|
sourcePoint2 = self.readIntPoint(command)
|
||||||
|
else:
|
||||||
|
sourceSize = self.readIntPoint(command, isPoint = False)
|
||||||
box = BoundingBox(sourcePoint, sourceSize)
|
box = BoundingBox(sourcePoint, sourceSize)
|
||||||
return box
|
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):
|
def readPoint(self, command, isPoint = True):
|
||||||
try:
|
try:
|
||||||
word = command.pop(0)
|
word = command.pop(0)
|
||||||
|
Reference in New Issue
Block a user