]> git.phdru.name Git - m_librarian.git/blobdiff - scripts/ml-initdb.py
Feat(glst): Report imported glst counter
[m_librarian.git] / scripts / ml-initdb.py
index 4445fc6f951ddac6dac3e4cfd7f995cbb554205a..71d3598e512bdd8475833b8ef44666d81d457696 100755 (executable)
@@ -1,13 +1,24 @@
 #! /usr/bin/env python
 
+import argparse
+from m_librarian.config import get_config
 from m_librarian.db import open_db, init_db
 from m_librarian.glst import import_glst
 
 if __name__ == '__main__':
-    open_db()
+    parser = argparse.ArgumentParser(description='Init')
+    parser.add_argument('-C', '--config', help='configuration file')
+    parser.add_argument('-D', '--database', help='database URI')
+    args = parser.parse_args()
+
+    if args.config:
+        get_config(args.config)  # Get and cache config file
+
+    open_db(args.database)
     init_db()
-    old, new = import_glst()
-    if old:
-        print "Imported %d genres (ignored %d existing)" % (new, old)
+    count_old, count_new = import_glst()
+    if count_old:
+        print("Imported %d genres (ignored %d existing)" % (
+            count_new, count_old))
     else:
-        print "Imported %d genres" % new
+        print("Imported %d genres" % count_new)