Exemplo n.º 1
0
    def rename(self):
        """Renames media file to formatted name.

        After parsing data from initial media filename and searching
        for additional data to using a data service, a formatted
        filename will be generated and the media file will be renamed
        to the generated name and optionally relocated.
        """
        renamer.execute(self.original, self.out_location)
        if cfg.CONF.move_files_enabled:
            LOG.debug('relocated: %s', self)
        else:
            LOG.debug('renamed: %s', self)
Exemplo n.º 2
0
    def rename(self):
        """Renames media file to formatted name.

        After parsing data from initial media filename and searching
        for additional data to using a data service, a formatted
        filename will be generated and the media file will be renamed
        to the generated name and optionally relocated.
        """
        renamer.execute(self.original, self.out_location)
        if cfg.CONF.move_files_enabled:
            LOG.debug('relocated: %s', self)
        else:
            LOG.debug('renamed: %s', self)
Exemplo n.º 3
0
    def test_execute(self):

        with mock.patch.object(os.path, 'isfile', return_value=True):
            self.assertIsNone(
                renamer.execute('/tmp/test_file.txt', 'Test_file.txt'))

        tempfile = self.create_tempfiles([('test_file', 'test data')])[0]
        new_file = os.path.join(os.path.dirname(tempfile), 'other_file.conf')
        renamer.execute(tempfile, new_file)
        self.assertThat(new_file, matchers.FileExists())
        self.assertThat(tempfile, matchers.Not(matchers.FileExists()))

        tempfiles = self.create_tempfiles([('test_file', 'test data'),
                                           ('other_file', 'test data')])
        self.CONF.set_override('overwrite_file_enabled', True)
        renamer.execute(tempfiles[0], tempfiles[1])
        self.assertThat(tempfiles[1], matchers.FileExists())
        self.assertThat(tempfiles[0], matchers.Not(matchers.FileExists()))

        tempfile = self.create_tempfiles([('my_file', 'test data')])[0]
        new_file = os.path.join(os.path.dirname(tempfile), 'alt_file.conf')
        self.CONF.set_override('dryrun', True)
        renamer.execute(tempfile, new_file)
        self.assertThat(tempfile, matchers.FileExists())
        self.assertThat(new_file, matchers.Not(matchers.FileExists()))
Exemplo n.º 4
0
    def test_execute(self):

        with mock.patch.object(os.path, 'isfile', return_value=True):
            self.assertIsNone(
                renamer.execute('/tmp/test_file.txt', 'Test_file.txt'))

        tempfile = self.create_tempfiles([('test_file', 'test data')])[0]
        new_file = os.path.join(os.path.dirname(tempfile), 'other_file.conf')
        renamer.execute(tempfile, new_file)
        self.assertThat(new_file, matchers.FileExists())
        self.assertThat(tempfile, matchers.Not(matchers.FileExists()))

        tempfiles = self.create_tempfiles([('test_file', 'test data'),
                                           ('other_file', 'test data')])
        self.CONF.set_override('overwrite_file_enabled', True)
        renamer.execute(tempfiles[0], tempfiles[1])
        self.assertThat(tempfiles[1], matchers.FileExists())
        self.assertThat(tempfiles[0], matchers.Not(matchers.FileExists()))

        tempfile = self.create_tempfiles([('my_file', 'test data')])[0]
        new_file = os.path.join(os.path.dirname(tempfile), 'alt_file.conf')
        self.CONF.set_override('dryrun', True)
        renamer.execute(tempfile, new_file)
        self.assertThat(tempfile, matchers.FileExists())
        self.assertThat(new_file, matchers.Not(matchers.FileExists()))