X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=scripts%2Fml-import.py;h=431a6d2d55d2b0158a6daa13bbe50695d7180e31;hb=d64c85c78598c984e7e468903fde25fb55e23883;hp=47c6b1b2056e39139221acb474571db305edf75c;hpb=0118f85c754acb6ddf519f32362b4c91c032ade6;p=m_librarian.git diff --git a/scripts/ml-import.py b/scripts/ml-import.py index 47c6b1b..431a6d2 100755 --- a/scripts/ml-import.py +++ b/scripts/ml-import.py @@ -13,7 +13,7 @@ if ttyProgressBar: from m_librarian.pbar import ml_ttyProgressBar if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Import') + parser = argparse.ArgumentParser(description='Import INPX files') parser.add_argument('-C', '--config', help='configuration file') parser.add_argument('-D', '--database', help='database URI') parser.add_argument('-P', '--no-pbar', action='store_true', @@ -26,9 +26,17 @@ if __name__ == '__main__': open_db(args.database) init_db() - import_glst() + + 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" % count_new) + + use_pbar = ttyProgressBar and not args.no_pbar and sys.stdout.isatty() for inpx in args.inpx: - if ttyProgressBar and not args.no_pbar: + if use_pbar: if len(inpx) > 25: pbar_fname = inpx[:22] + '...' else: @@ -40,4 +48,11 @@ if __name__ == '__main__': print("Ok") else: import_inpx(inpx) - update_counters() + if use_pbar: + print("Updating counters", end=': ') + sys.stdout.flush() + pbar = ml_ttyProgressBar() + update_counters(pbar_cb=pbar) + print("Ok") + else: + update_counters()