X-Git-Url: https://git.phdru.name/?p=xsetbg.git;a=blobdiff_plain;f=reload_db.py;h=3c9c56e64ef3d26ca6fcc0f3cd9f9589309fff4d;hp=fe25e864781546343bd97233a1c87786913c161d;hb=HEAD;hpb=962838424251685fe3ed18fd446c2ab5ecc6c32b diff --git a/reload_db.py b/reload_db.py index fe25e86..c12607a 100755 --- a/reload_db.py +++ b/reload_db.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Reload a dump into DB This file is a part of XSetBg. @@ -19,17 +19,16 @@ def convert_str(s): return int(float(s)) -dump_file = open(sys.argv[1], 'r') +dump_file = open(sys.argv[1], 'r', + encoding=xsetbg_conf.get("images", "fs_encoding")) xsetbg_db = recreate_db() count_new = count_old = count_updated = 0 -fs_encoding = xsetbg_conf.get("images", "fs_encoding") with SQLiteMassInsert() as txn: for line in dump_file: id, timestamp, filename = line.strip().split(None, 2) id = convert_str(id) timestamp = convert_str(timestamp) - filename = filename.decode(fs_encoding) try: if id: row = xsetbg_db.get(id) @@ -55,6 +54,6 @@ with SQLiteMassInsert() as txn: dump_file.close() -print "New images:", count_new -print "Existing images:", count_old -print "Updated images:", count_updated +print("New images:", count_new) +print("Existing images:", count_old) +print("Updated images:", count_updated)