summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/reassociate_similar_images.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-12 15:43:15 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:24 +0100
commit13b9ef1c26bb89349a15be94db7d01512e270d5a (patch)
treebb7c35ca850f60028c576ee42e3fb95db20a64be /ishtar_common/management/commands/reassociate_similar_images.py
parent7e6c628ff9f4d27609efda613b790f87bbeacea1 (diff)
downloadIshtar-13b9ef1c26bb89349a15be94db7d01512e270d5a.tar.bz2
Ishtar-13b9ef1c26bb89349a15be94db7d01512e270d5a.zip
Refactor - clean
Diffstat (limited to 'ishtar_common/management/commands/reassociate_similar_images.py')
-rw-r--r--ishtar_common/management/commands/reassociate_similar_images.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/ishtar_common/management/commands/reassociate_similar_images.py b/ishtar_common/management/commands/reassociate_similar_images.py
index 0dbb3a765..9e52bc6f6 100644
--- a/ishtar_common/management/commands/reassociate_similar_images.py
+++ b/ishtar_common/management/commands/reassociate_similar_images.py
@@ -127,9 +127,9 @@ class Command(BaseCommand):
for attr in attributes:
ref_value = getattr(ref_item, attr)
other_value = getattr(item, attr)
+ if not other_value:
+ continue
if ref_value:
- if not other_value:
- continue
if other_value != ref_value:
if attr == 'title' and merged_title:
setattr(ref_item, 'title', merged_title)
@@ -138,8 +138,6 @@ class Command(BaseCommand):
(attr, ref_value, other_value)
)
else:
- if not other_value:
- continue
setattr(ref_item, attr, other_value)
base_csv = [
@@ -184,11 +182,11 @@ class Command(BaseCommand):
item.delete()
nb_merged_items += 1
if not quiet:
- out.write(u"\n")
+ out.write("\n")
n = datetime.datetime.now().isoformat().split('.')[0].replace(':', '-')
if conflicts:
- filename = output_path + u"{}-conflict.csv".format(n)
+ filename = output_path + "{}-conflict.csv".format(n)
with open(filename, 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(
@@ -202,10 +200,10 @@ class Command(BaseCommand):
for conflict in conflicts:
writer.writerow(conflict)
if not quiet:
- out.write(u"* {} conflicted items ({})\n".format(
+ out.write("* {} conflicted items ({})\n".format(
nb_conflicted_items, filename))
if merged:
- filename = output_path + u"{}-merged.csv".format(n)
+ filename = output_path + "{}-merged.csv".format(n)
with open(filename, 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(
@@ -218,7 +216,7 @@ class Command(BaseCommand):
for merge in merged:
writer.writerow(merge)
if not quiet:
- out.write(u"* {} merged items ({})\n".format(nb_merged_items,
+ out.write("* {} merged items ({})\n".format(nb_merged_items,
filename))
if not quiet:
out.write("* {} distinct images\n".format(distinct_image))