def item_completed(self, results, item, info):
for result in [x for ok, x in results if ok]:
path = result['path']
slug = slugify(item['designer'])
settings = get_project_settings()
storage = settings.get('IMAGES_STORE')
target_path = os.path.join(storage, slug, os.path.basename(path))
path = os.path.join(storage, path)
# If path doesn't exist, it will be created
if not os.path.exists(os.path.join(storage, slug)):
os.makedirs(os.path.join(storage, slug))
if not os.rename(path, target_path):
raise DropItem("Could not move image to target folder")
if self.IMAGES_RESULT_FIELD in item.fields:
item[self.IMAGES_RESULT_FIELD] = [x for ok, x in results if ok]
return item
答案是here和{a2}。在
基本上重写item_completed方法,并根据图像来自的列表包含图像保存位置的逻辑。在
相关问题 更多 >
编程相关推荐