Exemple #1
0
 def on_add_loop(self, field=None):
     """
     Adds a new video background loop and creates the associated thumbnail image for the UI.
     :param field:
     """
     files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
                                         Settings().value(self.settings_section + '/last directory'),
                                         self.on_new_file_masks)
     if files:
         Settings().setValue(self.settings_section + '/last directory', split_filename(files[0])[0])
         for f in files:
             self.application.set_busy_cursor()
             shutil.copy(f, self.path)
             self.create_loop_thumbnail(split_filename(f)[1])
             self.application.set_normal_cursor()
     self.load_loops()
Exemple #2
0
 def on_add_loop(self, field=None):
     """
     Adds a new video background loop and creates the associated thumbnail image for the UI.
     :param field:
     """
     files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
                                         Settings().value(self.settings_section + '/last directory'),
                                         self.on_new_file_masks)
     if files:
         Settings().setValue(self.settings_section + '/last directory', split_filename(files[0])[0])
         for f in files:
             self.application.set_busy_cursor()
             shutil.copy(f, self.path)
             self.create_loop_thumbnail(split_filename(f)[1])
             self.application.set_normal_cursor()
     self.load_loops()
Exemple #3
0
    def split_filename_with_file_path_test(self):
        """
        Test the split_filename() function with a path to a file
        """
        # GIVEN: A path to a file.
        file_path = '/home/user/myfile.txt'
        wanted_result = ('/home/user', 'myfile.txt')
        with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
            mocked_is_file.return_value = True

            # WHEN: Split the file name.
            result = split_filename(file_path)

            # THEN: A tuple should be returned.
            assert result == wanted_result, 'A tuple with the directory and file name should have been returned.'
Exemple #4
0
    def split_filename_with_dir_path_test(self):
        """
        Test the split_filename() function with a path to a directory
        """
        # GIVEN: A path to a dir.
        file_path = '/home/user/mydir'
        wanted_result = ('/home/user/mydir', '')
        with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
            mocked_is_file.return_value = False

            # WHEN: Split the file name.
            result = split_filename(file_path)

            # THEN: A tuple should be returned.
            assert result == wanted_result, \
                'A two-entry tuple with the directory and file name (empty) should have been returned.'
Exemple #5
0
    def split_filename_with_file_path_test(self):
        """
        Test the split_filename() function with a path to a file
        """
        # GIVEN: A path to a file.
        if os.name == 'nt':
            file_path = 'C:\\home\\user\\myfile.txt'
            wanted_result = ('C:\\home\\user', 'myfile.txt')
        else:
            file_path = '/home/user/myfile.txt'
            wanted_result = ('/home/user', 'myfile.txt')
        with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
            mocked_is_file.return_value = True

            # WHEN: Split the file name.
            result = split_filename(file_path)

            # THEN: A tuple should be returned.
            self.assertEqual(wanted_result, result, 'A tuple with the dir and file name should have been returned')
Exemple #6
0
    def split_filename_with_file_path_test(self):
        """
        Test the split_filename() function with a path to a file
        """
        # GIVEN: A path to a file.
        if os.name == 'nt':
            file_path = 'C:\\home\\user\\myfile.txt'
            wanted_result = ('C:\\home\\user', 'myfile.txt')
        else:
            file_path = '/home/user/myfile.txt'
            wanted_result = ('/home/user', 'myfile.txt')
        with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
            mocked_is_file.return_value = True

            # WHEN: Split the file name.
            result = split_filename(file_path)

            # THEN: A tuple should be returned.
            self.assertEqual(
                wanted_result, result,
                'A tuple with the dir and file name should have been returned')
Exemple #7
0
    def split_filename_with_dir_path_test(self):
        """
        Test the split_filename() function with a path to a directory
        """
        # GIVEN: A path to a dir.
        if os.name == 'nt':
            file_path = 'C:\\home\\user\\mydir'
            wanted_result = ('C:\\home\\user\\mydir', '')
        else:
            file_path = '/home/user/mydir'
            wanted_result = ('/home/user/mydir', '')
        with patch('openlp.core.utils.os.path.isfile') as mocked_is_file:
            mocked_is_file.return_value = False

            # WHEN: Split the file name.
            result = split_filename(file_path)

            # THEN: A tuple should be returned.
            self.assertEqual(
                wanted_result, result,
                'A two-entry tuple with the directory and file name (empty) should have been returned.'
            )