chore: black

This commit is contained in:
Guillaume Castagnino 2022-08-27 09:59:58 +02:00
parent 2b9e48249a
commit dafe17fceb
Signed by: casta
SSH key fingerprint: SHA256:PtJi7zHrXiSWdLApi+BdpmmbITeLq6cI7LZtgsuAtyk

View file

@ -1,32 +1,43 @@
#!/usr/bin/python
#!/usr/bin/env python
import os
import sqlite3
shotwell = sqlite3.connect(os.getenv('HOME', '.') + '/.local/share/shotwell/data/photo.db')
shotwell = sqlite3.connect(
os.getenv("HOME", ".") + "/.local/share/shotwell/data/photo.db"
)
shotwell.row_factory = sqlite3.Row
for c in shotwell.execute('SELECT id, rating, filename FROM PhotoTable p'):
report = "thumb%0.16x\t" % c['id']
report += "%d\t%d\t" % ( c['id'], c['rating'] )
tags = [t['name'] for t in [tag for tag in shotwell.execute('SELECT name FROM TagTable WHERE photo_id_list LIKE ?', ('%%thumb%0.16x%%' % c['id'], ))]]
for c in shotwell.execute("SELECT id, rating, filename FROM PhotoTable p"):
report = "thumb%0.16x\t" % c["id"]
report += "%d\t%d\t" % (c["id"], c["rating"])
tags = [
t["name"]
for t in [
tag
for tag in shotwell.execute(
"SELECT name FROM TagTable WHERE photo_id_list LIKE ?",
("%%thumb%0.16x%%" % c["id"],),
)
]
]
report += ",".join(tags)
report += "\t%s" % c['filename']
report += "\t%s" % c["filename"]
if len(tags) > 0:
#print(report)
# print(report)
# create exiv2 cmp file
cmd_file = c['filename'] + '.cmd'
cmd_file = c["filename"] + ".cmd"
f = open(cmd_file, "a")
for t in tags:
print("set Xmp.dc.subject XmpBag %s" % (t), file = f)
print("set Xmp.digiKam.TagsList %s" % (t), file = f)
print("set Xmp.dc.subject XmpBag %s" % (t), file=f)
print("set Xmp.digiKam.TagsList %s" % (t), file=f)
f.close()
# create xmp sidecar
command = u'''exiv2 -eX -m "%s" "%s"''' % (cmd_file, c['filename'])
command = '''exiv2 -eX -m "%s" "%s"''' % (cmd_file, c["filename"])
print(command)
good_sidecar = c['filename'] + '.xmp'
bad_sidecar = c['filename'][:-4] + '.xmp'
ret = os.system(command.encode('utf-8'))
good_sidecar = c["filename"] + ".xmp"
bad_sidecar = c["filename"][:-4] + ".xmp"
ret = os.system(command.encode("utf-8"))
if ret != 0:
print("warning: exiv command return %d, ran: %s" % (ret, command))
else: