Exemple #1
0
    def _format_filename(self, new_dirname, new_filename, metadata, settings, naming_format):
        old_filename = new_filename
        new_filename, ext = self._clean_file_extension(new_filename)

        if naming_format:
            new_filename = self._script_to_filename(naming_format, metadata, ext, settings)
            if not new_filename:
                new_filename = old_filename
            if not settings['rename_files']:
                new_filename = os.path.join(os.path.dirname(new_filename), old_filename)
            if not settings['move_files']:
                new_filename = os.path.basename(new_filename)
            win_compat = IS_WIN or settings['windows_compatibility']
            new_filename = make_short_filename(new_dirname, new_filename, win_compat)
            new_filename = make_save_path(new_filename, win_compat=win_compat, mac_compat=IS_MACOS)
        return new_filename
Exemple #2
0
 def test_replace_leading_dots(self):
     path = '.foo/.bar'
     self.assertEqual('_foo/_bar', make_save_path(path))
Exemple #3
0
 def test_decompose_precomposed_chars(self):
     path = 'foo/\u00E9bar'  # é
     self.assertEqual('foo/\u0065\u0301bar', make_save_path(path, mac_compat=True))
Exemple #4
0
 def test_replace_trailing_dots(self):
     path = 'foo./bar.'
     self.assertEqual(path, make_save_path(path))
     self.assertEqual('foo_/bar_', make_save_path(path, win_compat=True))