Esempio n. 1
0
    def __load_po_class(self, path):
        self.table_and_test_file_tabs.table.clear_table()

        if not os.path.exists(path):
            show_dialog_path_doesnt_exist(self, path)
        if not is_correct_python_file(path):
            show_dialog(self, u'File name is incorrect: %s' % path,
                        u'Bad file name')
        else:
            folder = os.path.dirname(path)
            files = [os.path.join(folder, p) for p in os.listdir(folder)
                     if is_correct_python_file(p)]
            self.cb_class_path.Clear()
            self.cb_class_path.AppendItems(files)
            self.cb_class_path.Select(files.index(path))
            try:
                self.__cur_po_class = PageObjectClass.parse_string_to_po_class(read_file(path))
                area = self.__cur_po_class.area
                self.image_panel.set_po_fields(self.__cur_po_class.fields)
                self.image_panel.load_image(self.__cur_po_class.img_path, area)

                self.cb_class_path.SetValue(self.__cur_po_class.file_path)

                self.table_and_test_file_tabs.load_po_class(self.__cur_po_class)
            except Exception:
                self.__cur_po_class = None
                show_error_dialog(self, traceback.format_exc(),
                                  u'Failed to open file %s' % path)
Esempio n. 2
0
 def __is_gen_data_correct(self):
     root_folder = self.__get_root_folder()
     class_name = self.txt_class_name.GetValue()
     area = self.txt_selected_area.GetValue()
     if not self.main_frame.get_browser():
         msg = u"Browser is not opened." + LINESEP + "Please open url."
         caption = u'Browser is not opened'
         show_dialog(self, msg, caption)
         return False
     elif not re.match(
             '\(\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*\)',
             area):
         msg = u"Selected area is not correct: '%s'" % area
         caption = u'Bad selected area'
         show_dialog(self, msg, caption)
         return False
     elif root_folder is None or not os.path.exists(root_folder):
         show_dialog_path_doesnt_exist(self, root_folder)
         return False
     elif len(class_name) == 0:  # if bad class_name
         msg = u"Unsupported name for class: '%s'" % class_name
         caption = u'Bad name for class'
         show_dialog(self, msg, caption)
         return False
     return True
Esempio n. 3
0
 def __load_tests_from_directory(self, evt):
     folder = self.__get_safe_path_from_root_folder(RootFolder.TESTS_FOLDER)
     if folder:
         dialog = DirDialog(self,
                            defaultPath=folder,
                            style=DD_DIR_MUST_EXIST)
         if dialog.ShowModal() == ID_OK:
             self.__load_tests_to_tree(dir_path=dialog.GetPath())
     else:
         show_dialog_path_doesnt_exist(self, folder)
Esempio n. 4
0
 def __open_class(self, evt):
     folder = self.GetTopLevelParent().get_root_folder()
     if folder:
         if RootFolder.PO_FOLDER in os.listdir(folder):
             folder = os.path.join(folder, RootFolder.PO_FOLDER)
         dialog = FileDialog(self, defaultDir=folder, wildcard=u'*.py')
         if dialog.ShowModal() == ID_OK:
             self.__load_po_class(dialog.GetPath())
     else:
         show_dialog_path_doesnt_exist(self, folder)
Esempio n. 5
0
 def __load_tests_from_directory(self, evt):
     folder = self.__get_safe_path_from_root_folder(RootFolder.TESTS_FOLDER)
     if folder:
         dialog = DirDialog(self,
                            defaultPath=folder,
                            style=DD_DIR_MUST_EXIST)
         if dialog.ShowModal() == ID_OK:
             self.__load_tests_to_tree(dir_path=dialog.GetPath())
     else:
         show_dialog_path_doesnt_exist(self, folder)
Esempio n. 6
0
 def __load_tests_from_files(self, evt):
     folder = self.__get_safe_path_from_root_folder(RootFolder.TESTS_FOLDER)
     if folder:
         dialog = FileDialog(self,
                             defaultDir=folder,
                             style=FD_OPEN | FD_FILE_MUST_EXIST | FD_MULTIPLE,
                             wildcard=u'*.py')
         if dialog.ShowModal() == ID_OK:
             self.__load_tests_to_tree(file_paths=dialog.GetPaths())
     else:
         show_dialog_path_doesnt_exist(self, folder)
Esempio n. 7
0
 def __load_tests_from_files(self, evt):
     folder = self.__get_safe_path_from_root_folder(RootFolder.TESTS_FOLDER)
     if folder:
         dialog = FileDialog(self,
                             defaultDir=folder,
                             style=FD_OPEN | FD_FILE_MUST_EXIST
                             | FD_MULTIPLE,
                             wildcard=u'*.py')
         if dialog.ShowModal() == ID_OK:
             self.__load_tests_to_tree(file_paths=dialog.GetPaths())
     else:
         show_dialog_path_doesnt_exist(self, folder)
Esempio n. 8
0
 def __is_gen_data_correct(self):
     root_folder = self.__get_root_folder()
     class_name = self.txt_class_name.GetValue()
     area = self.txt_selected_area.GetValue()
     if not self.main_frame.get_browser():
         msg = u"Browser is not opened." + LINESEP + "Please open url."
         caption = u'Browser is not opened'
         show_dialog(self, msg, caption)
         return False
     elif not re.match('\(\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*\)', area):
         msg = u"Selected area is not correct: '%s'" % area
         caption = u'Bad selected area'
         show_dialog(self, msg, caption)
         return False
     elif root_folder is None or not os.path.exists(root_folder):
         show_dialog_path_doesnt_exist(self, root_folder)
         return False
     elif len(class_name) == 0:  # if bad class_name
         msg = u"Unsupported name for class: '%s'" % class_name
         caption = u'Bad name for class'
         show_dialog(self, msg, caption)
         return False
     return True