# HG changeset patch # User ymh # Date 1533154900 -7200 # Node ID b5f3daa8640034f8ac7cb25a557688e54ee438d7 # Parent cce5f3e52ec9745685d66e4cfe232ecab9083f77 again, correct image destination filename diff -r cce5f3e52ec9 -r b5f3daa86400 src/iconolab/management/commands/importimages.py --- a/src/iconolab/management/commands/importimages.py Wed Aug 01 19:05:31 2018 +0200 +++ b/src/iconolab/management/commands/importimages.py Wed Aug 01 22:21:40 2018 +0200 @@ -18,10 +18,13 @@ def handle(self, *args, **options): raise NotImplementedError + def get_valid_filename(self, natural_key): + return text.get_valid_filename(natural_key.replace('|', '__')) + def get_image_dir(self, natural_key, collection): return os.path.join( collection.name, - text.get_valid_filename(natural_key.replace('|', '__')) + self.get_valid_filename(natural_key) ) ## @@ -62,7 +65,10 @@ image_file_name_fill = int(math.log10(len(image_files)))+1 for i, image in enumerate(image_files): (_, ext) = os.path.splitext(image) - dest_image_name = "{0}_{1:0{2}d}.jpg".format(natural_key, i+1, image_file_name_fill) + dest_image_name = "{0}_{1:0{2}d}.jpg".format( + self.get_valid_filename(natural_key), + i+1, + image_file_name_fill) image_path = os.path.join(target_item_image_dir, dest_image_name) if options.get('no-jpg-conversion') or ext in settings.NO_IMG_CONVERSION_EXTS: print('##### Copying file %s to %s without converting'%(str(image), image_path))