def get_files_list(self, folder_path):
     temp_files_names = sort_names_like_windows(
         names_list=os.listdir(folder_path))
     temp_files_names_absolute = get_files_names_absolute_list(
         temp_files_names, folder_path)
     result = []
     for i in range(len(temp_files_names)):
         if os.path.isdir(temp_files_names_absolute[i]):
             continue
         if os.path.getsize(temp_files_names_absolute[i]) == 0:
             continue
         result.append(temp_files_names[i])
     return result
    def update_files_with_drag_and_drop(self, paths_list):
        duplicate_flag = False
        not_duplicate_files_absolute_path_list = []
        not_duplicate_files_list = []
        duplicate_files_list = []
        new_files_absolute_path_list = []
        for path in paths_list:
            if os.path.isfile(path):
                if os.path.getsize(path) == 0:
                    continue
                new_files_absolute_path_list.append(path)
            else:
                new_files_absolute_path_list.extend(
                    sort_names_like_windows(
                        get_files_names_absolute_list(
                            self.get_files_list(path), path)))

        for new_file_name in new_files_absolute_path_list:
            if os.path.basename(new_file_name).lower() in map(
                    str.lower, self.files_names_list):
                duplicate_flag = True
                duplicate_files_list.append(os.path.basename(new_file_name))
            else:
                not_duplicate_files_absolute_path_list.append(new_file_name)
                not_duplicate_files_list.append(
                    os.path.basename(new_file_name))
                self.files_names_list.append(os.path.basename(new_file_name))
        self.attachment_source_lineEdit.stop_check_path = True
        self.attachment_source_lineEdit.setText(self.drag_and_dropped_text)
        self.is_drag_and_drop = True
        self.folder_path = ""
        self.files_names_absolute_list.extend(
            not_duplicate_files_absolute_path_list)
        self.files_size_list.extend(
            get_files_size_with_absolute_path_list(
                not_duplicate_files_absolute_path_list))
        self.files_checked_list.extend(
            [True] * len(not_duplicate_files_absolute_path_list))
        self.update_total_size()
        self.show_files_list()
        self.attachment_source_lineEdit.stop_check_path = False
        if duplicate_flag:
            info_message = "One or more files have the same name with the old files will be " \
                           "skipped:"
            for file_name in duplicate_files_list:
                info_message += "\n" + file_name
            warning_dialog = WarningDialog(
                window_title="Duplicate files names",
                info_message=info_message,
                parent=self.window())
            warning_dialog.execute_wth_no_block()
 def update_files_lists(self, folder_path):
     if folder_path == "" or folder_path.isspace():
         self.folder_path = ""
         self.attachment_source_lineEdit.setText("")
         return
     try:
         self.folder_path = folder_path
         self.files_names_list = self.get_files_list(self.folder_path)
         self.files_names_absolute_list = get_files_names_absolute_list(
             self.files_names_list, self.folder_path)
         self.files_size_list = get_files_size_list(
             files_list=self.files_names_list, folder_path=self.folder_path)
     except Exception as e:
         invalid_path_dialog = InvalidPathDialog()
         invalid_path_dialog.execute()
 def update_files_lists(self, folder_path):
     if folder_path == "" or folder_path.isspace():
         self.folder_path = ""
         if self.is_drag_and_drop:
             new_files_absolute_path_list = []
             self.files_names_list = []
             for file_absolute_path in self.files_names_absolute_list_with_dropped_files:
                 if os.path.isdir(file_absolute_path):
                     continue
                 if os.path.getsize(file_absolute_path) == 0:
                     continue
                 new_files_absolute_path_list.append(file_absolute_path)
                 self.files_names_list.append(
                     os.path.basename(file_absolute_path))
             self.attachment_source_lineEdit.stop_check_path = True
             self.attachment_source_lineEdit.setText(
                 self.drag_and_dropped_text)
             self.is_drag_and_drop = True
             self.folder_path = ""
             self.files_names_absolute_list = new_files_absolute_path_list.copy(
             )
             self.files_size_list = get_files_size_with_absolute_path_list(
                 new_files_absolute_path_list)
             self.files_checked_list = ([True] *
                                        len(new_files_absolute_path_list))
             self.attachment_source_lineEdit.stop_check_path = False
             self.update_total_size()
         else:
             self.attachment_source_lineEdit.setText("")
         return
     try:
         self.is_drag_and_drop = False
         self.folder_path = folder_path
         self.files_names_list = self.get_files_list(self.folder_path)
         self.files_names_absolute_list = get_files_names_absolute_list(
             self.files_names_list, self.folder_path)
         self.files_size_list = get_files_size_list(
             files_list=self.files_names_list, folder_path=self.folder_path)
         self.files_checked_list = ([True] *
                                    len(self.files_names_absolute_list))
     except Exception as e:
         invalid_path_dialog = InvalidPathDialog()
         invalid_path_dialog.execute()
 def get_files_list(self, new_extensions):
     temp_files_names = sort_names_like_windows(
         names_list=os.listdir(self.current_folder_path))
     temp_files_names_absolute = get_files_names_absolute_list(
         temp_files_names, self.current_folder_path)
     result = []
     for i in range(len(temp_files_names)):
         if os.path.isdir(temp_files_names_absolute[i]):
             continue
         for j in range(len(new_extensions)):
             temp_file_extension_start_index = temp_files_names[i].rfind(
                 ".")
             if temp_file_extension_start_index == -1:
                 continue
             temp_file_extension = temp_files_names[i][
                 temp_file_extension_start_index + 1:]
             if temp_file_extension.lower() == new_extensions[j].lower():
                 result.append(temp_files_names[i])
                 break
     return result
Пример #6
0
 def get_files_list(self, folder_path):
     temp_files_names = sort_names_like_windows(
         names_list=os.listdir(folder_path))
     temp_files_names_absolute = get_files_names_absolute_list(
         temp_files_names, folder_path)
     current_extensions = self.video_extensions_comboBox.currentData()
     result = []
     for i in range(len(temp_files_names)):
         if os.path.isdir(temp_files_names_absolute[i]):
             continue
         if os.path.getsize(temp_files_names_absolute[i]) == 0:
             continue
         for j in range(len(current_extensions)):
             temp_file_extension_start_index = temp_files_names[i].rfind(
                 ".")
             if temp_file_extension_start_index == -1:
                 continue
             temp_file_extension = temp_files_names[i][
                 temp_file_extension_start_index + 1:]
             if temp_file_extension.lower() == current_extensions[j].lower(
             ):
                 result.append(temp_files_names[i])
                 break
     return result
 def update_files_lists(self, folder_path):
     if folder_path == "" or folder_path.isspace():
         self.folder_path = ""
         if self.is_drag_and_drop:
             new_files_absolute_path_list = []
             self.files_names_list = []
             self.folders_paths = []
             current_extensions = self.video_extensions_comboBox.currentData(
             )
             for file_absolute_path in self.files_names_absolute_list_with_dropped_files:
                 if os.path.isdir(file_absolute_path):
                     continue
                 if os.path.getsize(file_absolute_path) == 0:
                     continue
                 temp_file_name = os.path.basename(file_absolute_path)
                 for j in range(len(current_extensions)):
                     temp_file_extension_start_index = temp_file_name.rfind(
                         ".")
                     if temp_file_extension_start_index == -1:
                         continue
                     temp_file_extension = temp_file_name[
                         temp_file_extension_start_index + 1:]
                     if temp_file_extension.lower(
                     ) == current_extensions[j].lower():
                         new_files_absolute_path_list.append(
                             file_absolute_path)
                         self.files_names_list.append(
                             os.path.basename(file_absolute_path))
                         if os.path.dirname(file_absolute_path
                                            ) not in self.folders_paths:
                             self.folders_paths.append(
                                 Path(os.path.dirname(file_absolute_path)))
                         break
             self.video_source_lineEdit.stop_check_path = True
             self.video_source_lineEdit.setText(self.drag_and_dropped_text)
             self.is_drag_and_drop = True
             self.folder_path = ""
             self.files_names_absolute_list = new_files_absolute_path_list.copy(
             )
             self.files_size_list = get_files_size_with_absolute_path_list(
                 new_files_absolute_path_list)
             self.files_names_absolute_list_with_dropped_files = new_files_absolute_path_list.copy(
             )
             self.files_names_checked_list = (
                 [True] * len(new_files_absolute_path_list))
             if len(new_files_absolute_path_list) > 0:
                 show_loading_dialog(new_files_absolute_path_list)
             self.video_source_lineEdit.stop_check_path = False
         else:
             self.video_source_lineEdit.setText("")
         return
     try:
         self.is_drag_and_drop = False
         self.folder_path = folder_path
         self.folders_paths = [Path(folder_path)]
         self.files_names_list = self.get_files_list(self.folder_path)
         self.files_names_absolute_list = get_files_names_absolute_list(
             self.files_names_list, self.folder_path)
         self.files_names_absolute_list_with_dropped_files = self.files_names_absolute_list.copy(
         )
         self.files_size_list = get_files_size_list(
             files_list=self.files_names_list, folder_path=self.folder_path)
         self.files_names_checked_list = (
             [True] * len(self.files_names_absolute_list))
         if len(self.files_names_absolute_list) > 0:
             show_loading_dialog(self.files_names_absolute_list)
     except Exception as e:
         invalid_path_dialog = InvalidPathDialog()
         invalid_path_dialog.execute()
    def update_files_with_drag_and_drop(self, paths_list):
        duplicate_flag = False
        not_duplicate_files_absolute_path_list = []
        not_duplicate_files_list = []
        duplicate_files_list = []
        new_files_absolute_path_list = []
        current_extensions = self.video_extensions_comboBox.currentData()
        for path in paths_list:
            if os.path.isfile(path):
                if os.path.getsize(path) == 0:
                    continue
                temp_file_name = os.path.basename(path)
                for j in range(len(current_extensions)):
                    temp_file_extension_start_index = temp_file_name.rfind(".")
                    if temp_file_extension_start_index == -1:
                        continue
                    temp_file_extension = temp_file_name[
                        temp_file_extension_start_index + 1:]
                    if temp_file_extension.lower(
                    ) == current_extensions[j].lower():
                        new_files_absolute_path_list.append(path)
                        break
            else:
                if os.path.dirname(path) not in self.folders_paths:
                    self.folders_paths.append(Path(os.path.dirname(path)))
                new_files_absolute_path_list.extend(
                    sort_names_like_windows(
                        get_files_names_absolute_list(
                            self.get_files_list(path), path)))

        for new_file_name in new_files_absolute_path_list:
            if os.path.basename(new_file_name).lower() in map(
                    str.lower, self.files_names_list):
                duplicate_flag = True
                duplicate_files_list.append(os.path.basename(new_file_name))
            else:
                not_duplicate_files_absolute_path_list.append(new_file_name)
                not_duplicate_files_list.append(
                    os.path.basename(new_file_name))
                self.files_names_list.append(os.path.basename(new_file_name))
                if os.path.dirname(new_file_name) not in self.folders_paths:
                    self.folders_paths.append(
                        Path(os.path.dirname(new_file_name)))
        self.video_source_lineEdit.stop_check_path = True
        self.video_source_lineEdit.setText(self.drag_and_dropped_text)
        self.is_drag_and_drop = True
        self.folder_path = ""
        self.files_names_absolute_list_with_dropped_files.extend(
            not_duplicate_files_absolute_path_list)
        self.files_names_absolute_list.extend(
            not_duplicate_files_absolute_path_list)
        self.files_size_list.extend(
            get_files_size_with_absolute_path_list(
                not_duplicate_files_absolute_path_list))
        self.files_names_checked_list.extend(
            [True] * len(not_duplicate_files_absolute_path_list))
        self.show_files_list()
        if len(not_duplicate_files_absolute_path_list) > 0:
            show_loading_dialog(not_duplicate_files_absolute_path_list)
        self.video_source_lineEdit.stop_check_path = False
        if duplicate_flag:
            info_message = "One or more files have the same name with the old files will be " \
                           "skipped:"
            for file_name in duplicate_files_list:
                info_message += "\n" + file_name
            warning_dialog = WarningDialog(
                window_title="Duplicate files names",
                info_message=info_message,
                parent=self.window())
            warning_dialog.execute_wth_no_block()