]> git.phdru.name Git - xsetbg.git/blobdiff - dump_db.py
Fix(DB): Fix column encoding
[xsetbg.git] / dump_db.py
index 97972991ba3169be555bb6dd1dbfe6dd7ff505fc..ca3c6a74be70213190721f1940f564607e9eb79a 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 """Dump the DB sorted by date
 
 This file is a part of XSetBg.
@@ -6,11 +6,15 @@ This file is a part of XSetBg.
 """
 
 import sys
-from m_lib.defenc import default_encoding
+from xsetbg_conf import xsetbg_conf
 from xsetbg_db import xsetbg_db
 
 if not xsetbg_db:
     sys.exit("Error: no database found")
 
+fs_encoding = xsetbg_conf.get("images", "fs_encoding")
 for row in xsetbg_db.select(orderBy='-last_shown'):
-    print(row.id, row.last_shown, row.full_name.encode(default_encoding))
+    sys.stdout.buffer.write(
+        ('%d %s %s\n' % (row.id, row.last_shown, row.full_name
+                         )).encode(fs_encoding)
+    )