class PointRequest (Request):
def __init__(self, msg, curve, block=0, default=None):
super(PointRequest, self).__init__('point', msg, default)
- self.options = options
+ self.curve = curve
+ self.block = block
class PointResponse (Response):
def __init__(self, value):
return msg.msg + d
def _string_request_parser(self, msg, response):
+ response = response.strip()
+ if response == '':
+ return msg.default
return response.strip()
def _float_request_prompt(self, msg):
return self._string_request_prompt(msg)
def _float_request_parser(self, msg, resposne):
+ if response.strip() == '':
+ return msg.default
return float(response)
def _selection_request_prompt(self, msg):
prompt = '? '
else:
prompt = '? [%d] ' % msg.default
- return '\n'.join([msg,options,prompt])
+ return '\n'.join([msg.msg,options,prompt])
def _selection_request_parser(self, msg, response):
+ if response.strip() == '':
+ return msg.default
+ return int(response)
+
+ def _point_request_prompt(self, msg):
+ block = msg.curve.data[msg.block]
+ block_info = ('(curve: %s, block: %s, %d points)'
+ % (msg.curve.name,
+ block.info['name'],
+ block.shape[0]))
+
+ if msg.default == None:
+ prompt = '? '
+ else:
+ prompt = '? [%d] ' % msg.default
+ return ' '.join([msg.msg,block_info,prompt])
+
+ def _point_request_parser(self, msg, response):
+ if response.strip() == '':
+ return msg.default
return int(response)