示例#1
0
 def next_state_base(self, text):
     if util.verify_response(text):
         self.write_variable("throw_away", True)
         self.context['data'] = self.read_variable(
             "loaded_file").content.split("\n")[1:]
         return sm.Print(["Great, thanks."
                          ]).when_done(self.get_when_done_state())
     return CheckHeader(force_ask=True).when_done(
         self.get_when_done_state())
示例#2
0
 def next_state_base(self, text):
     file_str = self.context['data']
     types = rows_and_types(split_line(file_str[0]))
     if not self.force_check:
         self.context["types"] = types
     if self.force_check or util.verify_response(text):
         print(types)
         dummy_frame = iris_objects.IrisDataframe(column_names=self.context['headers'], column_types=["String" for _ in types], data=[types])
         print_types = sm.Print([{"type":"collection_select_one", "value":dummy_frame.generate_spreadsheet_data()}]) #util.prettify_data(type_obj)}])
         return sm.DoAll([print_types, ChangeIndex()]).when_done(self.get_when_done_state())
     return None #True, Done().when_done(self.get_when_done_state())
示例#3
0
 def next_state_base(self, text):
     file_str = self.context['data']
     types = rows_and_types(split_line(file_str[0]))
     if not self.force_check:
         self.context["types"] = types
     if self.force_check or util.verify_response(text):
         type_obj = {
             i: {
                 "name": self.context["headers"][i],
                 "type": self.context["types"][i],
                 "example": split_line(self.context["data"][0])[i]
             }
             for i, _ in enumerate(self.context["headers"])
         }
         print_types = sm.Print([{
             "type": "data",
             "value": util.prettify_data(type_obj)
         }])
         return sm.DoAll([print_types, ChangeIndex()
                          ]).when_done(self.get_when_done_state())
     return None  #True, Done().when_done(self.get_when_done_state())
示例#4
0
 def next_state_base(self, text):
     if util.verify_response(text):
         return ChangeIndex().when_done(self.get_when_done_state())
     return None #True, Done().when_done(self.get_when_done_state())
示例#5
0
 def base_hint(self, text):
     if text == "":
         return ["yes", "no"]
     if util.verify_response(text):
         return ["yes"]
     return ["no"]