# HG changeset patch # User ymh # Date 1533140281 -7200 # Node ID 7b479c7b6861e3e8ba4942fd1a5397f6cc66b131 # Parent 9de311703ab99cfef94864df8a0c910d55ba68d8 change the way images collection files are imported and named. upgrade iconolab dependency and increment version nb diff -r 9de311703ab9 -r 7b479c7b6861 src/iconolab_episteme/__init__.py --- a/src/iconolab_episteme/__init__.py Wed Aug 01 14:43:44 2018 +0200 +++ b/src/iconolab_episteme/__init__.py Wed Aug 01 18:18:01 2018 +0200 @@ -1,4 +1,4 @@ -VERSION = (0, 3, 3, "final", 0) +VERSION = (0, 3, 4, "final", 0) VERSION_STR = ".".join(map(lambda i:"%02d" % (i,), VERSION[:2])) diff -r 9de311703ab9 -r 7b479c7b6861 src/iconolab_episteme/management/commands/importimages.py --- a/src/iconolab_episteme/management/commands/importimages.py Wed Aug 01 14:43:44 2018 +0200 +++ b/src/iconolab_episteme/management/commands/importimages.py Wed Aug 01 18:18:01 2018 +0200 @@ -63,9 +63,9 @@ '## Converting image and moving it to static dir, creating Image and Item objects') print('### Images will be stored in ' + os.path.join(settings.MEDIA_ROOT, 'uploads')) - for dirname, dirs, files in os.walk(self.source_dir): + for dirname, _, files in os.walk(self.source_dir): for filename in files: - filename_without_extension, extension = os.path.splitext(filename) + filename_without_extension, _ = os.path.splitext(filename) if imghdr.what(os.path.join(dirname, filename)) is None: continue @@ -74,27 +74,20 @@ continue with open(json_path) as json_data: - eso_data = json.load(json_data) - eso_image = eso_data['image'] + item_data = json.load(json_data) + item_image = item_data['image'] path_images = os.path.join(dirname, filename) image_list = [path_images] - image_dir = filename_without_extension - natural_key = ItemMetadata.get_natural_key(collection, eso_image['id']) + natural_key = ItemMetadata.get_natural_key(collection, item_image['id']) if ItemMetadata.objects.filter( item__collection=collection, natural_key=natural_key).exists(): print('#### An item with ' + natural_key +' for natural key, already exists in database in the import collection') else: - try: - os.mkdir(os.path.join(settings.MEDIA_ROOT, 'uploads', image_dir)) - print(image_dir, "directory created") - except FileExistsError: - print(image_dir, "directory already exists") - self.create_item_and_metadata( - natural_key, collection, eso_data, image_list, options, self.source_dir) + natural_key, collection, item_data, image_list, options) print('# All done!') \ No newline at end of file diff -r 9de311703ab9 -r 7b479c7b6861 src/setup.py --- a/src/setup.py Wed Aug 01 14:43:44 2018 +0200 +++ b/src/setup.py Wed Aug 01 18:18:01 2018 +0200 @@ -123,7 +123,7 @@ setup_requires=['setuptools_scm'], install_requires=[ "Django >= 2.0", - "iconolab == 0.1.7", + "iconolab == 0.1.8", "django-appconf", "django-comments-xtd", "django-contrib-comments",