Beispiel #1
0
 def send_token(self):
     token = self.token
     self.token = None
     self.eos = True
     return ActionResult(production=(token,))
Beispiel #2
0
 def new_request(self, url, params, header):
     url = url.encode('ascii', 'ignore')
     self.request = self['http'].get(url, params, header)
     return ActionResult()
Beispiel #3
0
 def handle_body(self):
     body = self['http'].body(self.request)
     self.reset_request()
     return ActionResult(production=(body, ))
Beispiel #4
0
 def dummy_action(self, input):
     return ActionResult(tokens_consumed=1,
                         tokens_produced=1,
                         production=(input, ))
Beispiel #5
0
 def start_timer(self, token):
     self.setup()
     return ActionResult(production=(token, ))
Beispiel #6
0
 def write(self, data):
     self.file.write_line(data)
     return ActionResult(tokens_consumed=1, tokens_produced=0, production=())
Beispiel #7
0
 def answer(self):
     result = self.result
     self.counter = 0
     self.result = 0
     return ActionResult(production=([result, self.type],))
Beispiel #8
0
 def eof(self):
     self.calvinsys.io.file.close(self.file)
     self.file = None
     return ActionResult(production=(EOSToken(), self.status_OK))
Beispiel #9
0
 def flush(self, input):
     return ActionResult(production=(input, ))
Beispiel #10
0
 def file_not_found(self):
     self.file_not_found = False  # Only report once
     return ActionResult(production=(EOSToken(), self.status_ERR))
Beispiel #11
0
 def readline(self):
     line = self.file.read_line()
     return ActionResult(production=(line, ))
Beispiel #12
0
 def exception_handler(self, action, args, context):
     return ActionResult(production=(ExceptionToken(), ))
Beispiel #13
0
 def sum(self, input):
     self.sum = self.sum + input
     return ActionResult(tokens_consumed=1,
                         tokens_produced=1,
                         production=(self.sum, ))
Beispiel #14
0
 def send_eos(self):
     self.eos = False
     return ActionResult(production=(EOSToken(),))
 def wrap_action(self, input):
     return ActionResult(tokens_consumed=1, tokens_produced=1, production=(self.wrapper.wrap(input), ))
Beispiel #16
0
 def clear(self):
     self.timer.ack()
     return ActionResult()
Beispiel #17
0
    def exception_handler(self, action, args, exceptions):
        self.calvinsys.io.file.close(self.file)
        self.file = None

        return ActionResult(tokens_consumed=1, tokens_produced=0, production=())
Beispiel #18
0
 def render_image(self, image):
     if not image is None:
         self.image.show_image(image, self.width, self.height)
     return ActionResult(production=())
Beispiel #19
0
 def divide(self, temperatures):
     self.result = (( self.result * self.counter ) + temperatures[0] )/ (self.counter + 1)
     self.counter += 1
     self.type = temperatures[1]
     return ActionResult(production=(['ignore','train'],))
Beispiel #20
0
 def exception_handler(self, action, args, context):
     return ActionResult(production=(self.default, ))
Beispiel #21
0
 def empty(self, trigger):
     return ActionResult()
Beispiel #22
0
 def load(self, string):
     try:
         res = self['json'].loads(string)
     except:
         res = self.default
     return ActionResult(production=(res, ))
Beispiel #23
0
 def verbose_action(self, input):
     return ActionResult(tokens_consumed=1,
                         tokens_produced=1,
                         production=("(" + str(input) + ")", ))
Beispiel #24
0
 def start_timer(self):
     self.start()
     result = self.rand_generator(self.low, self.high)
     return ActionResult(production=([result, self.type],))
Beispiel #25
0
 def passthrough(self, token):
     self.timer.ack()
     return ActionResult(production=(token, ))
Beispiel #26
0
 def action(self, sample, tok):
     if sample is True:
         self.held = copy(tok)
     return ActionResult(production=(self.held, ))
Beispiel #27
0
 def handle_headers(self):
     self.received_headers = True
     status = self['http'].status(self.request)
     headers = self['http'].headers(self.request)
     return ActionResult(production=(status, headers))
Beispiel #28
0
 def post_update(self, status):
     self['twitter'].post_update(status)
     return ActionResult()
Beispiel #29
0
 def handle_empty_body(self):
     self.reset_request()
     return ActionResult()
Beispiel #30
0
 def incoming(self, token):
     self.token = token
     return ActionResult()